Skip to content

Commit

Permalink
Fix typo for the word uncertainty
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyle Kaplan committed Jul 18, 2024
1 parent a420e4a commit 2e000a8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 26 deletions.
8 changes: 4 additions & 4 deletions src/muler/echelle.py
Original file line number Diff line number Diff line change
Expand Up @@ -822,7 +822,7 @@ def to apply to smooth surrounding pixels (e.g. scipy.ndimage.median_filter)
def apply(self, method=np.nansum, **kwargs):
"""
Apply any method to the spectrum. This is very general and can be used for many
things. Uncertainity is propogated.
things. Uncertainty is propogated.
Parameters
----------
Expand All @@ -840,7 +840,7 @@ def to apply to spectrum (e.g. np.nansum to collapse a multidimensional spectrum

def __pow__(self, power):
"""Take flux to a power while preserving the exiting flux units.
Uuseful for airmass correction. Uncertainity is propogated by keeping the
Uuseful for airmass correction. Uncertainty is propogated by keeping the
singal-to-noise constant.
Parameters
Expand Down Expand Up @@ -1116,7 +1116,7 @@ def __truediv__(self, other):

def __pow__(self, power):
"""Take flux to a power while preserving the exiting flux units.
Uuseful for airmass correction. Uncertainity is propagated by keeping the
Uuseful for airmass correction. Uncertainty is propagated by keeping the
singal-to-noise constant.
Parameters
Expand Down Expand Up @@ -1175,7 +1175,7 @@ def to apply to smooth surrounding pixels (e.g. scipy.ndimage.median_filter)
def apply(self, method=np.nansum, **kwargs):
"""
Apply any method to the spectral list. This is very general and can be used for many
things. Uncertainity is propogated.
things. Uncertainty is propogated.
Parameters
----------
Expand Down
44 changes: 22 additions & 22 deletions src/muler/igrins.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ def readPLP(plppath, date, frameno, waveframeno, dim='1D'):
return spec_all


def getUncertainityFilepath(filepath):
"""Returns path for uncertainity file (.variance.fits or .sn.fits)
def getUncertaintyFilepath(filepath):
"""Returns path for uncertainty file (.variance.fits or .sn.fits)
Will first search for a .variance.fits file but if that does not exist
will search for a .sn.fits file.
Expand All @@ -102,11 +102,11 @@ def getUncertainityFilepath(filepath):
Returns
-------
uncertainityFilepath: string
uncertaintyFilepath: string
Returns the file path to the uncertianity (.variance.fits or .sn.fits) file.
"""
if ".spec_a0v.fits" in filepath: #Grab base file name for the uncertainity file
if ".spec_a0v.fits" in filepath: #Grab base file name for the uncertainty file
path_base = filepath[:-14]
elif ".spec_flattened.fits" in filepath:
path_base = filepath[:-20]
Expand All @@ -119,7 +119,7 @@ def getUncertainityFilepath(filepath):
return path_base + '.var2d.fits'
else:
raise Exception(
"The file .var2d.fits does not exist in the same path as the spectrum file to get the uncertainity. Please provide one of these files in the same directory as your spectrum file."
"The file .var2d.fits does not exist in the same path as the spectrum file to get the uncertainty. Please provide one of these files in the same directory as your spectrum file."
)
else:
if os.path.exists(path_base + '.variance.fits'): #Prefer .variance.fits file
Expand All @@ -128,7 +128,7 @@ def getUncertainityFilepath(filepath):
return path_base + '.sn.fits'
else:
raise Exception(
"Neither .variance.fits or .sn.fits exists in the same path as the spectrum file to get the uncertainity. Please provide one of these files in the same directory as your spectrum file."
"Neither .variance.fits or .sn.fits exists in the same path as the spectrum file to get the uncertainty. Please provide one of these files in the same directory as your spectrum file."
)

def getSlitProfile(filepath, band, slit_length):
Expand All @@ -152,7 +152,7 @@ def getSlitProfile(filepath, band, slit_length):
y: float
Flux of beam profile across the slit
"""
if ".spec_a0v.fits" in filepath: #Grab base file name for the uncertainity file
if ".spec_a0v.fits" in filepath: #Grab base file name for the uncertainty file
path_base = filepath[:-14]
elif ".spec_flattened.fits" in filepath:
path_base = filepath[:-20]
Expand Down Expand Up @@ -275,7 +275,7 @@ def __init__(
self.instrumental_resolution = 45_000.0
self.file = file

#False if variance.fits file used for uncertainity, true if sn.fits file used for uncertainity
#False if variance.fits file used for uncertainty, true if sn.fits file used for uncertainty

if file is not None:

Expand All @@ -289,14 +289,14 @@ def __init__(
raise NameError("Cannot identify file as an IGRINS spectrum")
grating_order = grating_order_offsets[band] + order

uncertainity_hdus = None #Default values
uncertainity = None
uncertainty_hdus = None #Default values
uncertainty = None
if cached_hdus is not None:
hdus = cached_hdus[0]
if "rtell" in file:
sn = hdus["SNR"].data[order]
else:
uncertainity_hdus = cached_hdus[1]
uncertainty_hdus = cached_hdus[1]
if wavefile is not None:
wave_hdus = cached_hdus[2]
else: #Read in files if cached_hdus are not provided
Expand All @@ -309,8 +309,8 @@ def __init__(
full_path = base_path + '/' + os.path.basename(wavefile)
wave_hdus = fits.open(full_path)
if "rtell" not in file and "spec_a0v" not in file:
uncertainty_filepath = getUncertainityFilepath(file)
uncertainity_hdus = fits.open(uncertainty_filepath, memmap=False)
uncertainty_filepath = getUncertaintyFilepath(file)
uncertainty_hdus = fits.open(uncertainty_filepath, memmap=False)
if '.sn.fits' in uncertainty_filepath:
sn_used = True
elif "rtell" in file: #If rtell file is used, grab SNR stored in extension
Expand All @@ -324,15 +324,15 @@ def __init__(
lamb = hdus["WAVELENGTH"].data[order].astype(np.float64) * u.micron
flux = hdus["SPEC_DIVIDE_A0V"].data[order].astype(np.float64) * u.ct
try:
uncertainity_hdus = [hdus["SPEC_DIVIDE_A0V_VARIANCE"]]
uncertainty_hdus = [hdus["SPEC_DIVIDE_A0V_VARIANCE"]]
sn_used = False
except:
print("Warning: Using older PLP versions of .spec_a0v.fits files which have no variance saved. Will grab .variance.fits file.")
elif ".spec_a0v.fits" in file:
lamb = hdus["WAVELENGTH"].data[order].astype(float) * u.micron
flux = hdus["SPEC_DIVIDE_A0V"].data[order].astype(float) * u.ct
try:
uncertainity_hdus = [hdus["SPEC_DIVIDE_A0V_VARIANCE"]]
uncertainty_hdus = [hdus["SPEC_DIVIDE_A0V_VARIANCE"]]
sn_used = False
except:
print("Warning: Using older PLP versions of .spec_a0v.fits files which have no variance saved. Will grab .variance.fits file.")
Expand All @@ -356,17 +356,17 @@ def __init__(
"m": grating_order,
"header": hdr,
}
if uncertainity_hdus is not None or ("rtell" in file):
if uncertainty_hdus is not None or ("rtell" in file):
if not sn_used: #If .variance.fits used
variance = uncertainity_hdus[0].data[order].astype(np.float64)
variance = uncertainty_hdus[0].data[order].astype(np.float64)
stddev = np.sqrt(variance)
if ("rtell" in file): #If using a rtell or spec_a0v file with a variance file, scale the stddev to preserve signal-to-noise
unprocessed_flux = hdus["TGT_SPEC"].data[order].astype(np.float64)
stddev *= (flux.value / unprocessed_flux)
else: #Else if .sn.fits (or SNR HDU in rtell file) used
if not "rtell" in file:
sn = uncertainity_hdus[0].data[order].astype(np.float64)
dw = np.gradient(lamb) #Divide out stuff the IGRINS PLP did to calculate the uncertainity per resolution element to get the uncertainity per pixel
sn = uncertainty_hdus[0].data[order].astype(np.float64)
dw = np.gradient(lamb) #Divide out stuff the IGRINS PLP did to calculate the uncertainty per resolution element to get the uncertainty per pixel
pixel_per_res_element = (lamb/40000.)/dw
sn_per_pixel = sn / np.sqrt(pixel_per_res_element)
stddev = flux.value / sn_per_pixel.value
Expand Down Expand Up @@ -490,9 +490,9 @@ def read(file, precache_hdus=True, wavefile=None):
if "SPEC_DIVIDE_A0V_VARIANCE" in hdus:
cached_hdus = [hdus, [hdus["SPEC_DIVIDE_A0V_VARIANCE"]]]
elif "rtell" not in file: #Default, if no rtell file is used
uncertainty_filepath = getUncertainityFilepath(file)
uncertainity_hdus = fits.open(uncertainty_filepath, memmap=False)
cached_hdus = [hdus, uncertainity_hdus]
uncertainty_filepath = getUncertaintyFilepath(file)
uncertainty_hdus = fits.open(uncertainty_filepath, memmap=False)
cached_hdus = [hdus, uncertainty_hdus]
if '.sn.fits' in uncertainty_filepath:
sn_used = True
else: #If rtell file is used
Expand Down

0 comments on commit 2e000a8

Please sign in to comment.