@@ -1109,6 +1109,7 @@ def __init__(
1109
1109
use_corfac = True ,
1110
1110
deredden = False ,
1111
1111
only_bands = None ,
1112
+ only_data = "ALL" ,
1112
1113
):
1113
1114
"""
1114
1115
Parameters
@@ -1132,6 +1133,9 @@ def __init__(
1132
1133
1133
1134
only_bands : list
1134
1135
Only read in the bands given
1136
+
1137
+ only_data : list
1138
+ Only read in the data given
1135
1139
"""
1136
1140
self .file = datfile
1137
1141
self .path = path
@@ -1146,9 +1150,9 @@ def __init__(
1146
1150
self .dereddened = deredden
1147
1151
1148
1152
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 )
1150
1154
1151
- def read (self , deredden = False , only_bands = None ):
1155
+ def read (self , deredden = False , only_bands = None , only_data = "ALL" ):
1152
1156
"""
1153
1157
Populate the object from a DAT file + spectral files
1154
1158
@@ -1159,12 +1163,15 @@ def read(self, deredden=False, only_bands=None):
1159
1163
Generally used to deredden standards.
1160
1164
only_bands : list
1161
1165
Only read in the bands given
1166
+ only_data : list
1167
+ Only read in the data given
1162
1168
"""
1163
1169
1164
1170
# open and read all the lines in the file
1165
1171
f = open (f"{ self .path } /{ self .file } " , "r" )
1166
1172
self .datfile_lines = list (f )
1167
1173
f .close ()
1174
+
1168
1175
# get the photometric band data
1169
1176
self .data ["BAND" ] = BandData ("BAND" )
1170
1177
self .data ["BAND" ].read_bands (self .datfile_lines , only_bands = only_bands )
@@ -1214,35 +1221,35 @@ def read(self, deredden=False, only_bands=None):
1214
1221
for line in self .datfile_lines :
1215
1222
if line [0 ] == "#" :
1216
1223
pass
1217
- elif "IUE" in line :
1224
+ elif "IUE" in line and ( "IUE" in only_data or only_data == "ALL" ) :
1218
1225
fname = _getspecfilename (line , self .path )
1219
1226
if os .path .isfile (fname ):
1220
1227
self .data ["IUE" ] = SpecData ("IUE" )
1221
1228
self .data ["IUE" ].read_iue (line , path = self .path )
1222
1229
else :
1223
1230
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" ) :
1225
1232
fname = _getspecfilename (line , self .path )
1226
1233
if os .path .isfile (fname ):
1227
1234
self .data ["FUSE" ] = SpecData ("FUSE" )
1228
1235
self .data ["FUSE" ].read_fuse (line , path = self .path )
1229
1236
else :
1230
1237
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" ) :
1232
1239
fname = _getspecfilename (line , self .path )
1233
1240
if os .path .isfile (fname ):
1234
1241
self .data ["STIS_Opt" ] = SpecData ("STIS_Opt" )
1235
1242
self .data ["STIS_Opt" ].read_stis (line , path = self .path )
1236
1243
else :
1237
1244
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" ) :
1239
1246
fname = _getspecfilename (line , self .path )
1240
1247
if os .path .isfile (fname ):
1241
1248
self .data ["STIS" ] = SpecData ("STIS" )
1242
1249
self .data ["STIS" ].read_stis (line , path = self .path )
1243
1250
else :
1244
1251
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" ) :
1246
1253
fname = _getspecfilename (line , self .path )
1247
1254
if os .path .isfile (fname ):
1248
1255
self .data ["SpeX_SXD" ] = SpecData ("SpeX_SXD" )
@@ -1254,7 +1261,7 @@ def read(self, deredden=False, only_bands=None):
1254
1261
)
1255
1262
else :
1256
1263
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" ) :
1258
1265
fname = _getspecfilename (line , self .path )
1259
1266
if os .path .isfile (fname ):
1260
1267
self .data ["SpeX_LXD" ] = SpecData ("SpeX_LXD" )
@@ -1266,7 +1273,7 @@ def read(self, deredden=False, only_bands=None):
1266
1273
)
1267
1274
else :
1268
1275
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" ) :
1270
1277
fname = _getspecfilename (line , self .path )
1271
1278
if os .path .isfile (fname ):
1272
1279
self .data ["IRS" ] = SpecData ("IRS" )
@@ -1278,7 +1285,7 @@ def read(self, deredden=False, only_bands=None):
1278
1285
)
1279
1286
else :
1280
1287
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" ) :
1282
1289
fname = _getspecfilename (line , self .path )
1283
1290
if os .path .isfile (fname ):
1284
1291
self .data ["NIRISS_SOSS" ] = SpecData ("NIRISS_SOSS" )
@@ -1288,7 +1295,7 @@ def read(self, deredden=False, only_bands=None):
1288
1295
)
1289
1296
else :
1290
1297
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" ) :
1292
1299
fname = _getspecfilename (line , self .path )
1293
1300
if os .path .isfile (fname ):
1294
1301
self .data ["NIRCam_SS" ] = SpecData ("NIRCam_SS" )
@@ -1298,7 +1305,7 @@ def read(self, deredden=False, only_bands=None):
1298
1305
)
1299
1306
else :
1300
1307
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" ) :
1302
1309
fname = _getspecfilename (line , self .path )
1303
1310
if os .path .isfile (fname ):
1304
1311
self .data ["MIRI_LRS" ] = SpecData ("MIRI_LRS" )
@@ -1308,7 +1315,7 @@ def read(self, deredden=False, only_bands=None):
1308
1315
)
1309
1316
else :
1310
1317
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" ) :
1312
1319
fname = _getspecfilename (line , self .path )
1313
1320
if os .path .isfile (fname ):
1314
1321
self .data ["MIRI_IFU" ] = SpecData ("MIRI_IFU" )
@@ -1318,7 +1325,7 @@ def read(self, deredden=False, only_bands=None):
1318
1325
)
1319
1326
else :
1320
1327
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" ) :
1322
1329
fname = _getspecfilename (line , self .path )
1323
1330
if os .path .isfile (fname ):
1324
1331
self .data ["MODEL_FULL_LOWRES" ] = SpecData ("MODEL_FULL_LOWRES" )
@@ -1328,7 +1335,7 @@ def read(self, deredden=False, only_bands=None):
1328
1335
)
1329
1336
else :
1330
1337
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" ) :
1332
1339
fname = _getspecfilename (line , self .path )
1333
1340
if os .path .isfile (fname ):
1334
1341
self .data ["MODEL_FULL" ] = SpecData ("MODEL_FULL" )
0 commit comments