-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3813aed
commit 3acab78
Showing
3 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
#Reading Gemini GMOS filters | ||
|
||
from astropy import units as u, constants as const | ||
from numpy import genfromtxt | ||
import pandas as pd | ||
import os | ||
from glob import glob | ||
|
||
def read_decam_filter(fname): | ||
""" | ||
Reading the bessell filter file into a dataframe | ||
Parameters | ||
---------- | ||
fname: ~str | ||
path to file to be read | ||
""" | ||
|
||
data = pd.DataFrame(genfromtxt(fname, usecols=(0, 1)), | ||
columns=['wavelength', 'transmission_lambda']) | ||
|
||
return data | ||
|
||
|
||
def read_dataset(fname_list, prefix, name_parser=None): | ||
""" | ||
Reading a whole list of filters | ||
Parameters | ||
---------- | ||
fname_list: list | ||
list of filenames | ||
prefix: str | ||
prefix for the dictionary keys | ||
Returns | ||
------- | ||
dict | ||
""" | ||
|
||
filter_dict = {} | ||
|
||
for fname in fname_list: | ||
if name_parser is not None: | ||
filter_name = name_parser(fname) | ||
else: | ||
filter_name = fname | ||
|
||
filter_path = os.path.join(prefix, filter_name) | ||
|
||
filter_dict[filter_path] = read_decam_filter(fname) | ||
|
||
return filter_dict | ||
|
||
|
||
|
||
def read_all_decam(): | ||
nameparser = (lambda fname: os.path.basename(fname).replace('DECam.', '')) | ||
return read_dataset(glob('DECam.?'), 'decam', | ||
nameparser) | ||
|
||
def save_to_hdf(filter_dict, hdf_file, mode='a'): | ||
|
||
fh = pd.HDFStore(hdf_file, mode=mode) | ||
|
||
for key in filter_dict: | ||
filter_dict[key].to_hdf(fh, key) | ||
|
||
fh.close() |
Binary file not shown.