Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Adding DHS to PandExo, including front end #89

Open
wants to merge 13 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 8 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
3 changes: 2 additions & 1 deletion pandexo/engine/justdoit.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"NIRSpec G395H":False,
"NIRSpec Prism":False,
"NIRCam F322W2":False,
"NIRCam F444W":False}
"NIRCam F444W":False,
"NIRCam DHS":False}


def print_instruments(verbose=True):
Expand Down
1 change: 1 addition & 0 deletions pandexo/engine/justplotit.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,7 @@ def jwst_noise(result_dict, plot=True, output_file= 'noise.html'):
y = result_dict['FinalSpectrum']['error_w_floor']*1e6
x = x[~np.isnan(y)]
y = y[~np.isnan(y)]

ymed = np.median(y)


Expand Down
7 changes: 5 additions & 2 deletions pandexo/engine/jwst.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ def compute_full_sim(dictinput,verbose=False):
#so create temp conf with 2 groups
if 'optimize' in str(conf['detector']['ngroup']):
conf_temp = deepcopy(conf)
if 'dhs' in conf['instrument']['aperture']:
#for DHS also need to swap to bright mode to get only the highest throughput spectra
conf_temp['instrument']['aperture'] = 'dhs0bright'
conf_temp['detector']['ngroup'] = 2
else:
conf_temp = conf
Expand All @@ -94,7 +97,7 @@ def compute_full_sim(dictinput,verbose=False):
exp_pars = i.the_detector.exposure_spec
tframe =exp_pars.tframe
nframe = exp_pars.nframe
nskip = exp_pars.nsample_skip
nskip = exp_pars.ndrop2

sat_unit = pandexo_input['observation']['sat_unit']

Expand Down Expand Up @@ -953,7 +956,7 @@ def as_dict(out, both_spec ,binned, timing, mag, sat_level, warnings, punit, unb
"Aperture": out['input']['configuration']['instrument']['aperture'],
"Disperser": out['input']['configuration']['instrument']['disperser'],
"Subarray": out['input']['configuration']['detector']['subarray'],
"Readmode": out['input']['configuration']['detector']['readmode'],
"Readmode": out['input']['configuration']['detector']['readout_pattern'],
"Filter": out['input']['configuration']['instrument']['filter'],
"Primary/Secondary": punit
}
Expand Down
18 changes: 14 additions & 4 deletions pandexo/engine/load_modes.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class SetDefaultModes():
- "NIRSpec Prism"
- "NIRCam F322W2"
- "NIRCam F444W"
- "NIRCam DHS"
- "WFC3 G102"
- "WFC3 G141"

Expand All @@ -34,8 +35,10 @@ class SetDefaultModes():
"""

def __init__(self, inst):
self.instrument = inst[0:inst.find(' ')].lower()
self.config = inst[inst.find(' ')+1:len(inst)].lower()
self.user_input=inst
self.instrument = inst.split(' ')[0].lower()
self.config =inst.split(' ')[1].lower()


def pick(self):
"""Points to specific instrument based on key choice
Expand Down Expand Up @@ -87,10 +90,17 @@ def nirspec(self):
def nircam(self):
"""Handles NIRCam template
"""
if 'dhs' in self.config:
add='dhs_'
else:
add=''
with open(os.path.join(os.path.dirname(__file__), "reference",
"nircam_input.json")) as data_file:
f"nircam_{add}input.json")) as data_file:
pandeia_data = json.load(data_file)
pandeia_data["configuration"]["instrument"]["filter"] = self.config

if 'dhs' not in self.config:
pandeia_data["configuration"]["instrument"]["filter"] = self.config

return pandeia_data

def miri(self):
Expand Down
72 changes: 72 additions & 0 deletions pandexo/engine/reference/nircam_dhs_input.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
{
"telescope":"jwst",
"scene":[ {
"id": 1,
"target": true,
"position": {
"ang_unit": "arcsec",
"x_offset": 0.0,
"y_offset": 0.0
},
"shape": {
"geometry": "point"
},
"spectrum": {
"extinction": {
"bandpass": "j",
"law": "mw_rv_31",
"unit": "mag",
"value": 0.0
},
"normalization": {
"type": "none"},
"sed": {
"sed_type": "input",
"spectrum": []
},
"lines": []
}
}],

"background_level": "medium",
"background":"ecliptic",
"calculation":{
"effects": {
"background": true,
"ipc": true,
"saturation": true
},
"noise": {
"crs": true,
"darkcurrent": true,
"ffnoise": false,
"readnoise": true,
"rn_correlation": true
}
},
"configuration":{
"instrument": {
"instrument": "nircam",
"mode": "sw_tsgrism",
"filter": "f150w2",
"aperture": "dhs0spec8",
"disperser": "dhs0"
},
"detector": {
"readout_pattern":"shallow2",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change shallow2 to rapid.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

"subarray": "sub256stripe4_dhs",
"ngroup": "optimize",
"nint": 1,
"nexp": 10
}
},
"strategy": {
"method": "specapphot",
"background_subtraction":true,
"aperture_size": 0.7,
"sky_annulus": [0.8,1.6],
"target_xy": [0.0, 0.0],
"reference_wavelength":null,
"units":"arcsec"
}
}
5 changes: 2 additions & 3 deletions pandexo/engine/reference/nircam_input.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,14 @@
"configuration":{
"instrument": {
"instrument": "nircam",
"mode": "ssgrism",
"mode": "lw_tsgrism",
"filter": "f444w",
"aperture": "lw",
"disperser": "grismr"
},
"detector": {
"readout_pattern":"rapid",
"readout_pattern":"shallow2",
"subarray": "subgrism64",
"readmode": "rapid",
"ngroup": "optimize",
"nint": 1,
"nexp": 10
Expand Down
3 changes: 2 additions & 1 deletion pandexo/engine/reference/wfc3_input.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"scanDirection": "Forward or Round Trip",
"schedulability":"30 or 100",
"windowSize": 20,
"useFirstOrbit":false
"useFirstOrbit":false,
"calculateRamp":false

}
}
16 changes: 15 additions & 1 deletion pandexo/engine/run_online.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,20 @@ def post(self):
pandata["configuration"]["instrument"]["filter"] = self.get_argument("nircammode")
pandata["configuration"]["detector"]["subarray"] = self.get_argument("nircamsubarray")

if instrument == "nircamdhs":
with open(os.path.join(os.path.dirname(__file__), "reference", "nircam_dhs_input.json")) as data_file:
pandata = json.load(data_file)
#sw or lw for display?
sw_or_lw = self.get_argument("nircammode")
filter_to_sim = f'nircam{sw_or_lw}'
if 'sw' in filter_to_sim:
pair_filter='nircamlw'
else:
pair_filter='nircamsw'
pandata["configuration"]["instrument"]["filter"] = self.get_argument(filter_to_sim)
pandata["configuration"]["instrument"]["pandexofilterpair"] = self.get_argument(pair_filter)
pandata["configuration"]["detector"]["subarray"] = self.get_argument("nircamsubarray")

if instrument == "niriss":
with open(os.path.join(os.path.dirname(__file__), "reference", "niriss_input.json")) as data_file:
pandata = json.load(data_file)
Expand All @@ -526,7 +540,7 @@ def post(self):
if pandata["configuration"]["detector"]["subarray"] == "substrip256":
pandata['strategy']['order'] = int(self.get_argument('nirissorders'))

pandata['configuration']['instrument']['instrument'] = instrument
pandata['configuration']['instrument']['instrument'] = instrument.replace('dhs','')

# write in optimal groups or set a number
try:
Expand Down
49 changes: 47 additions & 2 deletions pandexo/engine/templates/new.html
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,8 @@ <h4>JWST Instrument Modes</h4>
<option value=""></option>
<option value="MIRI">MIRI Low Resolution Spectroscopy</option>
<option value="NIRSpec">NIRSpec Bright Object Time Series</option>
<option value="NIRCam">NIRCam Grism Time Series</option>
<option value="NIRCam">NIRCam Long Wave Only Grism Time Series</option>
<option value="NIRCamDHS">NIRCam Long Wave & Short Wave Grism Time Series</option>
<option value="NIRISS">NIRISS Single Object Slitless Spectroscopy</option>
</select>
</div>
Expand Down Expand Up @@ -376,6 +377,47 @@ <h4>JWST Instrument Modes</h4>
</div>
</div>

<div class="col-md-9" id="NIRCamDHS">
<div class="col-md-3" style="padding-left: 0;">
<select id="nircamsw" name="nircamsw" onchange="showForm()" class="form-control" data-placeholder="Select SW Filter">
<option value=""></option>
<option value="f070w">F070W, ~0.6-0.8 um</option>
<option value="f090w">F090W, ~0.8-1 um</option>
<option value="f115w">F115W, ~1-1.2 um</option>
<option value="f150w2">F150W2, ~1-1.9 um</option>
<option value="f200w">F200W, ~1.7-2 um</option>
</select>
</div>
<div class="col-md-3" style="padding-left: 0;">
<select id="nircamlw" name="nircamlw" onchange="showForm()" class="form-control" data-placeholder="Select LW Filter">
<option value=""></option>
<option value="f322w2">F322W2, 2.7-4 um</option>
<option value="f444w">F444W, 4-5 um</option>
</select>
</div>
<div class="col-md-3" style="padding-right: 0;">
<select id="nircamsubarray" name="nircamsubarray" onchange="showForm()" class="form-control" data-placeholder="Select NIRCam Subarray">
<option value=""></option>
<option value="sub40stripe1_dhs">sub40stripe1 DHS (tframe=0.21)</option>
<option value="sub80stripe2_dhs">sub80stripe2 DHS (tframe=0.42)</option>
<option value="sub160stripe4_dhs"> sub160stripe4 DHS (tframe=0.84)</option>
<option value="sub256stripe4_dhs">sub256stripe4 DHS (tframe=1.3)</option>
</select>
</div>
<div class="col-md-3" style="padding-right: 0;">
<select id="nircammode" name="nircammode" onchange="showForm()" class="form-control" data-placeholder="Display Simulation For?">
<option value=""></option>
<option value="sw">Short wave</option>
<option value="lw">Long wave</option>
</select>
</div>
<div class="col-md-9" style="padding-right: 0;">
<p class="help-block">1) There are separate calculations for the short and long wavelength channels even though these observations occur simultaneously. Take caution to use the same Instrument Setup and Detector Setup in both the SW Grism Time Series and LW Grism Time Series calculations for a given target to correctly evaluate expected SNR. </p>
<p class="help-block">2) SW Filter wavelength ranges cited in the dropdown menu are only for guidance. The exact numbers dependt on the choice of LW filter <a href="https://jwst-docs.stsci.edu/jwst-near-infrared-camera/nircam-observing-modes/nircam-time-series-observations/nircam-short-wavelength-grism-time-series#gsc.tab=0">(see JDOX Table 3)</a></p>
</div>
</div>


<div class="col-md-4" id="NIRISS">
<select id="nirissmode" name="nirissmode" onchange="show_dropdown()" class="form-control" data-placeholder="Select NIRISS Mode">
<option value=""></option>
Expand Down Expand Up @@ -556,7 +598,7 @@ <h4>JWST Instrument Modes</h4>
/* Instrument Selection */
$("#instrument").change(function () {
$("#instrument-mode-section").removeClass("hidden");
$("#MIRI, #NIRSpec, #NIRISS, #NIRCam").addClass("hidden");
$("#MIRI, #NIRSpec, #NIRISS, #NIRCam, #NIRCamDHS").addClass("hidden");
var selopt = $("#instrument").val();
switch (selopt) {
case "MIRI":
Expand All @@ -571,6 +613,9 @@ <h4>JWST Instrument Modes</h4>
case "NIRCam":
$("#NIRCam").removeClass("hidden");
break;
case "NIRCamDHS":
$("#NIRCamDHS").removeClass("hidden");
break;
}
});
});
Expand Down