Skip to content
This repository has been archived by the owner on Apr 23, 2021. It is now read-only.

Sweet spot #78

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion awesimsoss/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@

__author__ = """Joe Filippazzo"""
__email__ = '[email protected]'
__version__ = '0.2.0'
__version__ = '0.3.4'

from .awesim import TSO, TestTSO, BlackbodyTSO, ModelTSO
83 changes: 68 additions & 15 deletions awesimsoss/awesim.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class TSO(object):
Generate NIRISS SOSS time series observations
"""
def __init__(self, ngrps, nints, star=None, planet=None, tmodel=None, snr=700,
filter='CLEAR', subarray='SUBSTRIP256', orders=[1, 2], nresets=0,
filter='CLEAR', subarray='SUBSTRIP256', orders=[1, 2], nresets=1,
obs_date=None, target='New Target', title=None, verbose=True):
"""
Initialize the TSO object and do all pre-calculations
Expand Down Expand Up @@ -118,26 +118,21 @@ def __init__(self, ngrps, nints, star=None, planet=None, tmodel=None, snr=700,
Example
-------
# Imports
import numpy as np
from awesimsoss import TSO, STAR_DATA
import astropy.units as q
from pkg_resources import resource_filename
star = np.genfromtxt(resource_filename('awesimsoss', 'files/scaled_spectrum.txt'), unpack=True)
star1D = [star[0]*q.um, (star[1]*q.W/q.m**2/q.um).to(q.erg/q.s/q.cm**2/q.AA)]
from awesimsoss import TSO
from hotsoss import utils

# Initialize simulation
tso = TSO(ngrps=3, nints=10, star=star1D)
tso = TSO(ngrps=3, nints=10, star=utils.STAR_DATA)
"""
# Metadata
self.verbose = verbose
self.target = target
self.title = title or '{} Simulation'.format(self.target)

# Set static values
self.gain = 1.61
self._star = None

# Set instance attributes for the exposure
self.gain = 1.61
self._pupil_wheel = 245.7600
self.obs_date = obs_date or Time.now()
self.ngrps = ngrps
self.nints = nints
Expand Down Expand Up @@ -328,7 +323,9 @@ def export(self, outfile, all_data=False):
mod.meta.instrument.name = 'NIRISS'
mod.meta.instrument.detector = 'NIS'
mod.meta.instrument.filter = self.filter
mod.meta.instrument.filter_position = self.filter_wheel
mod.meta.instrument.pupil = 'GR700XD'
mod.meta.instrument.pupil_position = self.pupil_wheel
mod.meta.exposure.type = 'NIS_SOSS'
mod.meta.exposure.nints = self.nints
mod.meta.exposure.ngroups = self.ngrps
Expand All @@ -338,8 +335,8 @@ def export(self, outfile, all_data=False):
mod.meta.exposure.frame_time = self.frame_time
mod.meta.exposure.group_time = self.group_time
mod.meta.exposure.duration = self.duration.to(q.s).value
mod.meta.exposure.nresets_at_start = 1
mod.meta.exposure.nresets_between_ints = 1
mod.meta.exposure.nresets_at_start = self.nresets
mod.meta.exposure.nresets_between_ints = self.nresets
mod.meta.subarray.name = self.subarray
mod.meta.subarray.xsize = data.shape[3]
mod.meta.subarray.ysize = data.shape[2]
Expand Down Expand Up @@ -420,12 +417,39 @@ def filter(self, filt):
caldata = fits.getdata(calfile)
self.photom = caldata[(caldata['pupil'] == 'GR700XD') & (caldata['filter'] == filt)]

# Set filter wheel position to default value
self._filter_wheel = 314.8667 if filt == 'F277W' else 74.8667

# Update the results
self._reset_data()

# Reset relative response function
self._reset_psfs()

@property
def filter_wheel(self):
"""Getter for the filter_wheel attribute"""
return self._filter_wheel

@filter_wheel.setter
def filter_wheel(self, pos):
"""Setter for the filter_wheel attribute

Properties
----------
pos: float
The filter wheel position to use
"""
# Check the value
if not isinstance(pos, (float, int)) or not 0 <= pos <= 360:
raise ValueError("'{}' not a supported filter wheel position. Try a float or integer value between 0 and 360.".format(pos))

# Set it
self._filter_wheel = pos

# Reset relative response function
self._reset_psfs()

@property
def info(self):
"""Summary table for the observation settings"""
Expand Down Expand Up @@ -526,8 +550,7 @@ def nrows(self):

@nrows.setter
def nrows(self, err):
"""Error when trying to change the number of rows
"""
"""Error when trying to change the number of rows"""
raise TypeError("The number of rows is fixed by setting the 'subarray' attribute.")

@property
Expand Down Expand Up @@ -694,6 +717,30 @@ def plot_ramp(self, order=None, noise=True, draw=True):
else:
return fig

@property
def pupil_wheel(self):
"""Getter for the pupil_wheel attribute"""
return self._pupil_wheel

@pupil_wheel.setter
def pupil_wheel(self, pos):
"""Setter for the pupil_wheel attribute

Properties
----------
pos: float
The pupil wheel position to use
"""
# Check the value
if not isinstance(pos, (float, int)) or not 0 <= pos <= 360:
raise ValueError("'{}' not a supported pupil wheel position. Try a float or integer value between 0 and 360.".format(pos))

# Set it
self._pupil_wheel = pos

# Reset relative response function
self._reset_psfs()

def _reset_data(self):
"""Reset the results to all zeros"""
# Check that all the appropriate values have been initialized
Expand Down Expand Up @@ -731,6 +778,12 @@ def _reset_psfs(self):
# Check that all the appropriate values have been initialized
if all([i in self.info for i in ['filter', 'subarray']]) and self.star is not None:

# TODO: Change filter wheel position dependencies here
print(self.filter_wheel)

# TODO: Change pupil wheel position dependencies here
print(self.pupil_wheel)

for order in self.orders:

# Get the wavelength map
Expand Down
Loading