Skip to content

Commit

Permalink
Use the new wavelength array in get_model
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomas Stolker committed Jun 4, 2020
1 parent 9b05097 commit c19d858
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 31 deletions.
21 changes: 15 additions & 6 deletions species/data/ames_cond.py
Expand Up @@ -178,14 +178,23 @@ def add_ames_cond(input_path: str,
fill=np.nan,
verbose=False)

# if np.isnan(np.sum(flux_resample)):
# raise ValueError(f'Resampling is only possible if the new wavelength '
# f'range ({wavelength[0]} - {wavelength[-1]} um) falls '
# f'sufficiently far within the wavelength range '
# f'({data[0, 0]} - {data[-1, 0]} um) of the input '
# f'spectra.')
#
# flux.append(flux_resample) # (W m-2 um-1)

if np.isnan(np.sum(flux_resample)):
raise ValueError(f'Resampling is only possible if the new wavelength '
f'range ({wavelength[0]} - {wavelength[-1]} um) falls '
f'sufficiently far within the wavelength range '
f'({data[0, 0]} - {data[-1, 0]} um) of the input '
f'spectra.')
flux.append(np.zeros(wavelength.shape[0]))

warnings.warn('The wavelength range should fall within the range of the '
'original wavelength sampling. Storing zeros instead.')

flux.append(flux_resample) # (W m-2 um-1)
else:
flux.append(flux_resample) # (W m-2 um-1)

print_message = 'Adding AMES-Cond model spectra... [DONE]'
print(f'\r{print_message:<71}')
Expand Down
44 changes: 20 additions & 24 deletions species/data/ames_dusty.py
Expand Up @@ -144,31 +144,27 @@ def add_ames_dusty(input_path: str,
fill=np.nan,
verbose=False)

if np.isnan(np.sum(flux_resample)):
raise ValueError(f'Resampling is only possible if the new wavelength '
f'range ({wavelength[0]} - {wavelength[-1]} um) falls '
f'sufficiently far within the wavelength range '
f'({data[0, 0]} - {data_wavel[-1, 0]} um) of the input '
f'spectra.')

flux.append(flux_resample) # (W m-2 um-1)

# try:
# flux.append(spectres.spectres(wavelength,
# data[:, 0],
# data[:, 1],
# fill=0.,
# verbose=False))
#
# except (ValueError, IndexError):
# flux.append(np.zeros(wavelength.shape[0]))
# if np.isnan(np.sum(flux_resample)):
# raise ValueError(f'Resampling is only possible if the new wavelength '
# f'range ({wavelength[0]} - {wavelength[-1]} um) falls '
# f'sufficiently far within the wavelength range '
# f'({data[0, 0]} - {data_wavel[-1, 0]} um) of the input '
# f'spectra.')
#
# warnings.warn(f'The wavelength range ({wavelength[0]:.2f}-{wavelength[-1]:.2f}'
# f' um) should fall within the range of the original '
# f'wavelength sampling ({data[0, 0]:.2f}-{data[-1, 0]:.2f} '
# f'um). Storing zeros for the flux of Teff={teff_val} '
# f'and log(g)={logg_val}, which will be corrected by the '
# f'\'write_data\' function afterwards.')
# flux.append(flux_resample) # (W m-2 um-1)

if np.isnan(np.sum(flux_resample)):
flux.append(np.zeros(wavelength.shape[0]))

warnings.warn(f'The wavelength range ({wavelength[0]:.2f}-{wavelength[-1]:.2f}'
f' um) should fall within the range of the original '
f'wavelength sampling ({data[0, 0]:.2f}-{data[-1, 0]:.2f} '
f'um). Storing zeros for the flux of Teff={teff_val} '
f'and log(g)={logg_val}, which will be corrected by the '
f'\'write_data\' function afterwards.')

else:
flux.append(flux_resample) # (W m-2 um-1)

print_message = 'Adding AMES-Dusty model spectra... [DONE]'
print(f'\r{print_message:<75}')
Expand Down
7 changes: 6 additions & 1 deletion species/read/read_model.py
Expand Up @@ -566,6 +566,11 @@ def get_model(self,
f'probably because the original wavelength range does not fully '
f'encompass the new wavelength range.')

if wavel_resample is None:
wavelength = self.wl_points
else:
wavelength = wavel_resample

# is_finite = np.where(np.isfinite(flux))[0]
#
# if wavel_resample is None:
Expand All @@ -581,7 +586,7 @@ def get_model(self,
model_box = box.create_box(boxtype='model',
model=self.model,
wavelength=wavelength,
flux=flux[is_finite],
flux=flux,
parameters=model_param,
quantity=quantity)

Expand Down

0 comments on commit c19d858

Please sign in to comment.