Skip to content

Commit da9c804

Browse files
authored
Merge pull request #139 from Chamani8/master
Separate stellar param fitting by wavelength region
2 parents d384414 + 970ae47 commit da9c804

File tree

2 files changed

+24
-17
lines changed

2 files changed

+24
-17
lines changed

measure_extinction/stardata.py

+22-15
Original file line numberDiff line numberDiff line change
@@ -1109,6 +1109,7 @@ def __init__(
11091109
use_corfac=True,
11101110
deredden=False,
11111111
only_bands=None,
1112+
only_data="ALL",
11121113
):
11131114
"""
11141115
Parameters
@@ -1132,6 +1133,9 @@ def __init__(
11321133
11331134
only_bands : list
11341135
Only read in the bands given
1136+
1137+
only_data : list
1138+
Only read in the data given
11351139
"""
11361140
self.file = datfile
11371141
self.path = path
@@ -1146,9 +1150,9 @@ def __init__(
11461150
self.dereddened = deredden
11471151

11481152
if self.file is not None:
1149-
self.read(deredden=deredden, only_bands=only_bands)
1153+
self.read(deredden=deredden, only_bands=only_bands, only_data=only_data)
11501154

1151-
def read(self, deredden=False, only_bands=None):
1155+
def read(self, deredden=False, only_bands=None, only_data="ALL"):
11521156
"""
11531157
Populate the object from a DAT file + spectral files
11541158
@@ -1159,12 +1163,15 @@ def read(self, deredden=False, only_bands=None):
11591163
Generally used to deredden standards.
11601164
only_bands : list
11611165
Only read in the bands given
1166+
only_data : list
1167+
Only read in the data given
11621168
"""
11631169

11641170
# open and read all the lines in the file
11651171
f = open(f"{self.path}/{self.file}", "r")
11661172
self.datfile_lines = list(f)
11671173
f.close()
1174+
11681175
# get the photometric band data
11691176
self.data["BAND"] = BandData("BAND")
11701177
self.data["BAND"].read_bands(self.datfile_lines, only_bands=only_bands)
@@ -1214,35 +1221,35 @@ def read(self, deredden=False, only_bands=None):
12141221
for line in self.datfile_lines:
12151222
if line[0] == "#":
12161223
pass
1217-
elif "IUE" in line:
1224+
elif "IUE" in line and ("IUE" in only_data or only_data == "ALL"):
12181225
fname = _getspecfilename(line, self.path)
12191226
if os.path.isfile(fname):
12201227
self.data["IUE"] = SpecData("IUE")
12211228
self.data["IUE"].read_iue(line, path=self.path)
12221229
else:
12231230
warnings.warn(f"{fname} does not exist", UserWarning)
1224-
elif "FUSE" in line:
1231+
elif "FUSE" in line and ("FUSE" in only_data or only_data == "ALL"):
12251232
fname = _getspecfilename(line, self.path)
12261233
if os.path.isfile(fname):
12271234
self.data["FUSE"] = SpecData("FUSE")
12281235
self.data["FUSE"].read_fuse(line, path=self.path)
12291236
else:
12301237
warnings.warn(f"{fname} does not exist", UserWarning)
1231-
elif "STIS_Opt" in line:
1238+
elif "STIS_Opt" in line and ("STIS_Opt" in only_data or only_data == "ALL"):
12321239
fname = _getspecfilename(line, self.path)
12331240
if os.path.isfile(fname):
12341241
self.data["STIS_Opt"] = SpecData("STIS_Opt")
12351242
self.data["STIS_Opt"].read_stis(line, path=self.path)
12361243
else:
12371244
warnings.warn(f"{fname} does not exist", UserWarning)
1238-
elif "STIS" in line:
1245+
elif "STIS" in line and ("STIS" in only_data or only_data == "ALL"):
12391246
fname = _getspecfilename(line, self.path)
12401247
if os.path.isfile(fname):
12411248
self.data["STIS"] = SpecData("STIS")
12421249
self.data["STIS"].read_stis(line, path=self.path)
12431250
else:
12441251
warnings.warn(f"{fname} does not exist", UserWarning)
1245-
elif "SpeX_SXD" in line:
1252+
elif "SpeX_SXD" in line and ("SpeX_SXD" in only_data or only_data == "ALL"):
12461253
fname = _getspecfilename(line, self.path)
12471254
if os.path.isfile(fname):
12481255
self.data["SpeX_SXD"] = SpecData("SpeX_SXD")
@@ -1254,7 +1261,7 @@ def read(self, deredden=False, only_bands=None):
12541261
)
12551262
else:
12561263
warnings.warn(f"{fname} does not exist", UserWarning)
1257-
elif "SpeX_LXD" in line:
1264+
elif "SpeX_LXD" in line and ("SpeX_LXD" in only_data or only_data == "ALL"):
12581265
fname = _getspecfilename(line, self.path)
12591266
if os.path.isfile(fname):
12601267
self.data["SpeX_LXD"] = SpecData("SpeX_LXD")
@@ -1266,7 +1273,7 @@ def read(self, deredden=False, only_bands=None):
12661273
)
12671274
else:
12681275
warnings.warn(f"{fname} does not exist", UserWarning)
1269-
elif ("IRS" in line) and "IRS15" not in line:
1276+
elif ("IRS" in line) and "IRS15" not in line and ("IRS" in only_data or only_data == "ALL"):
12701277
fname = _getspecfilename(line, self.path)
12711278
if os.path.isfile(fname):
12721279
self.data["IRS"] = SpecData("IRS")
@@ -1278,7 +1285,7 @@ def read(self, deredden=False, only_bands=None):
12781285
)
12791286
else:
12801287
warnings.warn(f"{fname} does not exist", UserWarning)
1281-
elif "NIRISS_SOSS" in line:
1288+
elif "NIRISS_SOSS" in line and ("NIRCam_SS" in only_data or only_data == "ALL"):
12821289
fname = _getspecfilename(line, self.path)
12831290
if os.path.isfile(fname):
12841291
self.data["NIRISS_SOSS"] = SpecData("NIRISS_SOSS")
@@ -1288,7 +1295,7 @@ def read(self, deredden=False, only_bands=None):
12881295
)
12891296
else:
12901297
warnings.warn(f"{fname} does not exist", UserWarning)
1291-
elif "NIRCam_SS" in line:
1298+
elif "NIRCam_SS" in line and ("NIRCam_SS" in only_data or only_data == "ALL"):
12921299
fname = _getspecfilename(line, self.path)
12931300
if os.path.isfile(fname):
12941301
self.data["NIRCam_SS"] = SpecData("NIRCam_SS")
@@ -1298,7 +1305,7 @@ def read(self, deredden=False, only_bands=None):
12981305
)
12991306
else:
13001307
warnings.warn(f"{fname} does not exist", UserWarning)
1301-
elif "MIRI_LRS" in line:
1308+
elif "MIRI_LRS" in line and ("MIRI_LRS" in only_data or only_data == "ALL"):
13021309
fname = _getspecfilename(line, self.path)
13031310
if os.path.isfile(fname):
13041311
self.data["MIRI_LRS"] = SpecData("MIRI_LRS")
@@ -1308,7 +1315,7 @@ def read(self, deredden=False, only_bands=None):
13081315
)
13091316
else:
13101317
warnings.warn(f"{fname} does not exist", UserWarning)
1311-
elif "MIRI_IFU" in line:
1318+
elif "MIRI_IFU" in line and ("MIRI_IFU" in only_data or only_data == "ALL"):
13121319
fname = _getspecfilename(line, self.path)
13131320
if os.path.isfile(fname):
13141321
self.data["MIRI_IFU"] = SpecData("MIRI_IFU")
@@ -1318,7 +1325,7 @@ def read(self, deredden=False, only_bands=None):
13181325
)
13191326
else:
13201327
warnings.warn(f"{fname} does not exist", UserWarning)
1321-
elif "MODEL_FULL_LOWRES" in line:
1328+
elif "MODEL_FULL_LOWRES" in line and ("MODEL_FULL_LOWRES" in only_data or only_data == "ALL"):
13221329
fname = _getspecfilename(line, self.path)
13231330
if os.path.isfile(fname):
13241331
self.data["MODEL_FULL_LOWRES"] = SpecData("MODEL_FULL_LOWRES")
@@ -1328,7 +1335,7 @@ def read(self, deredden=False, only_bands=None):
13281335
)
13291336
else:
13301337
warnings.warn(f"{fname} does not exist", UserWarning)
1331-
elif "MODEL_FULL" in line:
1338+
elif "MODEL_FULL" in line and ("MODEL_FULL" in only_data or only_data == "ALL"):
13321339
fname = _getspecfilename(line, self.path)
13331340
if os.path.isfile(fname):
13341341
self.data["MODEL_FULL"] = SpecData("MODEL_FULL")

measure_extinction/utils/merge_stis_spec.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ def read_stis_archive_format(filename):
100100
outname = args.outname
101101
else:
102102
outname = args.starname.lower()
103-
stis_file = "%s_stis_%s.fits" % (outname, args.waveregion)
104-
rb_stis.write("%s/%s" % (args.outpath, stis_file), overwrite=True)
103+
stis_file = "%s/%s_stis_%s.fits" % (args.outpath, outname, args.waveregion)
104+
rb_stis.write(stis_file, overwrite=True)
105105

106106
# plot the original and merged Spectra
107107
fontsize = 14

0 commit comments

Comments
 (0)