File tree Expand file tree Collapse file tree 2 files changed +35
-1
lines changed Expand file tree Collapse file tree 2 files changed +35
-1
lines changed Original file line number Diff line number Diff line change @@ -168,6 +168,39 @@ def write_fits_BinTable_file(
168
168
hdu_list .writeto (output_path , overwrite = True )
169
169
170
170
171
+ def read_fits_to_dict (file_path ):
172
+ """Read Fits To Dict.
173
+
174
+ Read FITS file and return dictionary.
175
+
176
+ Parameters
177
+ ----------
178
+ file_path : str
179
+ input file path
180
+
181
+ Returns
182
+ -------
183
+ dict
184
+ file content
185
+
186
+ Raises
187
+ ------
188
+ IOError
189
+ if input file is not found
190
+ """
191
+ if not os .path .exists (file_path ):
192
+ raise IOError (f"Input file '{ file_path } ' not found" )
193
+
194
+ hdu_list = fits .open (file_path )
195
+ data_input = hdu_list [1 ].data
196
+ col_names = hdu_list [1 ].data .dtype .names
197
+ data = {}
198
+ for col_name in col_names :
199
+ data [col_name ] = data_input [col_name ]
200
+
201
+ return data
202
+
203
+
171
204
def bin_edges2centers (bin_edges ):
172
205
"""Bin Edges To Centers.
173
206
Original file line number Diff line number Diff line change @@ -43,7 +43,8 @@ def savefig(fname, close_fig=True):
43
43
fname : str
44
44
output file name
45
45
close_fig : bool, optional
46
- closes figure if True (default)
46
+ closes figure if ``True`` (default); chose ``False``
47
+ to display figure in a jupyter notebook
47
48
48
49
"""
49
50
plt .savefig (fname , facecolor = "w" , bbox_inches = "tight" )
You can’t perform that action at this time.
0 commit comments