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

REL-4638: F2 ITC calculation of exposure time & number of exposures to achieve S/N #2323

Merged
merged 6 commits into from
Jan 26, 2025
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import edu.gemini.spModel.guide.StandardGuideOptions;
import edu.gemini.spModel.obsclass.ObsClass;
import edu.gemini.spModel.obscomp.InstConstants;
import edu.gemini.spModel.gemini.flamingos2.Flamingos2;
import edu.gemini.spModel.gemini.ghost.Ghost;

import java.util.ArrayList;
Expand Down Expand Up @@ -379,23 +380,26 @@ public final ConfigCreatorResult createGsaoiConfig(final GsaoiParameters gsaoiPa
return result;
}

public final ConfigCreatorResult createF2Config(final Flamingos2Parameters f2Params, final int numExp) {
final ConfigCreatorResult result = createCommonConfig(numExp);
public final ConfigCreatorResult createF2Config(
final Flamingos2Parameters f2Params,
final Flamingos2.ReadMode readMode,
final int numExp,
final double exposureTime) {

final ConfigCreatorResult result = createCommonConfig(numExp, exposureTime);

for (final Config step : result.getConfig()) {
step.putItem(ReadModeKey, (f2Params.readMode()));
step.putItem(ReadModeKey, readMode);
step.putItem(InstInstrumentKey, SPComponentType.INSTRUMENT_FLAMINGOS2);
step.putItem(DisperserKey, f2Params.grism());
step.putItem(FPUKey, f2Params.mask());
if (itcParams.telescope().getWFS().equals(GuideProbe.Type.PWFS)) {
step.putItem(GuideWithPWFS2Key, StandardGuideOptions.Value.guide);
} else if (itcParams.telescope().getWFS().equals(GuideProbe.Type.OIWFS)) {
step.putItem(GuideWithOIWFSKey, StandardGuideOptions.Value.guide);

}
}
return result;

}
}

Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@

import java.io.PrintWriter;
import java.util.UUID;
import java.util.logging.Logger;

/**
* Helper class for printing F2 calculation results to an output stream.
*/
public final class Flamingos2Printer extends PrinterBase implements OverheadTablePrinter.PrinterWithOverhead {
private static final Logger Log = Logger.getLogger(Flamingos2Printer.class.getName());

private final PlottingDetails pdp;
private final Flamingos2Recipe recipe;
Expand All @@ -33,8 +35,8 @@ public Flamingos2Printer(final ItcParameters p, final Flamingos2Parameters instr
this.pdp = pdp;
this.recipe = new Flamingos2Recipe(p, instr);
this.isImaging = p.observation().calculationMethod() instanceof Imaging;
this.p = p;
this.instr = instr;
this.p = p;
this.instr = instr;
}

/**
Expand All @@ -58,6 +60,8 @@ private void writeSpectroscopyOutput(final UUID id, final SpectroscopyResult res

// we know this is Flamingos
final Flamingos2 instrument = (Flamingos2) result.instrument();
final CalculationMethod calcMethod = p.observation().calculationMethod();

final double iqAtSource = result.iqCalc().getImageQuality();

_println("");
Expand All @@ -68,7 +72,16 @@ private void writeSpectroscopyOutput(final UUID id, final SpectroscopyResult res

_println("");

_printRequestedIntegrationTime(result);
if (calcMethod instanceof SpectroscopyInt) {
double exposureTime = recipe.getExposureTime();
int numberExposures = recipe.getNumberExposures();
_println(String.format(
"Total integration time = %.2f seconds (%d x %.2f s), of which %.2f seconds is on source.",
numberExposures * exposureTime, numberExposures, exposureTime,
exposureTime * numberExposures * result.observation().sourceFraction()));
} else {
_printRequestedIntegrationTime(result);
}

_println("");

Expand Down Expand Up @@ -99,7 +112,6 @@ private void writeSpectroscopyOutput(final UUID id, final SpectroscopyResult res

}


private void writeImagingOutput(final ImagingResult result, final ItcImagingResult s) {

// we know this is Flamingos
Expand Down Expand Up @@ -139,7 +151,13 @@ private String flamingos2ToString(final Flamingos2 instrument) {
for (final TransmissionElement te : instrument.getComponents()) {
s += "<LI>" + te.toString() + "<BR>";
}
s += "<LI>Read Noise: " + instrument.getReadNoiseString() + "\n";

// Highlight the read mode if what was specified in the web form does not match what was calculated:
Log.fine("readMode (instrument) = " + instrument.getReadMode().toString());
Log.fine("readMode (recipe) = " + recipe.getReadMode().toString());
s += (instrument.getReadMode() != recipe.getReadMode()) ? "<LI style=\"color:darkorange\">" : "<LI>";
s += "Read Mode: " + recipe.getReadMode().toString() + "\n";
s += "<LI>Read Noise: " + recipe.getReadMode().readNoise() + " e-\n";

if (instrument.getFocalPlaneMask() != FPUnit.FPU_NONE)
s += "<LI>Focal Plane Mask: " + instrument.getFocalPlaneMask().getSlitWidth() + " pix slit\n";
Expand All @@ -149,10 +167,9 @@ private String flamingos2ToString(final Flamingos2 instrument) {
return s;
}


public ConfigCreator.ConfigCreatorResult createInstConfig(int numberExposures) {
ConfigCreator cc = new ConfigCreator(p);
return cc.createF2Config(instr, numberExposures);
return cc.createF2Config(instr, recipe.getReadMode(), numberExposures, recipe.getExposureTime());
}

public ItcOverheadProvider getInst() {
Expand All @@ -173,5 +190,7 @@ public double getRecenterInterval() {
return this.getRecentInterval();
}

public int getNumberExposures() { throw new Error("Not implemented"); }
public int getNumberExposures() {
return recipe.getNumberExposures();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public static String printParameterSummary(final PlottingDetails pdp) {
sb.append("Output:\n<LI>Spectra ");
switch (pdp.getPlotLimits()) {
case AUTO: sb.append("autoscaled."); break;
case USER: sb.append("plotted over range " + pdp.getPlotWaveL()*1000 + " - " + pdp.getPlotWaveU()*1000); break;
case USER: sb.append("plotted over range " + pdp.getPlotWaveL()/1000 + " - " + pdp.getPlotWaveU()/1000 + " µm"); break;
default: throw new Error();
}
sb.append("\n");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ private OverheadTablePrinter(PrinterWithOverhead printer,
} else if (calcMethod instanceof SpectroscopyS2N) {
numOfExposures = ((SpectroscopyS2N) calcMethod).exposures();
} else if (calcMethod instanceof ImagingExp) {
numOfExposures = ((GmosPrinter) printer).recipe.getNumberExposures();
numOfExposures = printer.getNumberExposures();
} else if (calcMethod instanceof SpectroscopyInt) {
numOfExposures = printer.getNumberExposures();
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ protected UUID cache(final ItcSpectroscopyResult result) {
/* TODO: this needs to be validated for spectroscopy for all instruments, find a better place to do this */
protected void validatePlottingDetails(final PlottingDetails pdp, final Instrument instrument) {
if (pdp != null && pdp.getPlotLimits().equals(PlottingDetails.PlotLimits.USER)) {
if (pdp.getPlotWaveL() * 1000 > instrument.getObservingEnd() || pdp.getPlotWaveU() * 1000 < instrument.getObservingStart()) {
throw new IllegalArgumentException("User limits for plotting do not overlap with filter.");
if (pdp.getPlotWaveL() > instrument.getObservingEnd() ||
pdp.getPlotWaveU() < instrument.getObservingStart()) {
throw new IllegalArgumentException("User limits for plotting do not overlap with instrument configuration.");
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion bundle/edu.gemini.itc.web/src/main/resources/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,6 @@ <h1>Integration Time Calculator Test Page</h1>
<br>
Plots of data files: <a href='../itcdocs/plots/index.html'>../itcdocs/plots/</a>
<hr>
<footer>Last updated 2024-Aug-27</footer>
<footer>Last updated 2025-Jan-24</footer>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -479,9 +479,27 @@
</tr>
<tr>
<td><input value="intTime" name="calcMethod" type="radio" /></td>
<td>Total integration time to achieve a S/N ratio of <input name="sigmaC" size="3" value="5" type="text" /> using an exposure time for each exposure of <input name="expTimeC" size="5" value="120" type="text" /> secs and with a fraction <input name="fracOnSourceC" size="4" value="1.0" type="text" /> of exposures that observe the source </td>
<td>Imaging integration time to achieve a S/N ratio of <input name="sigmaC" size="3" value="5" type="text" /> using an exposure time for each exposure of <input name="expTimeC" size="5" value="120" type="text" /> secs and with a fraction <input name="fracOnSourceC" size="4" value="1.0" type="text" /> of exposures that observe the source </td>

</tr>
<tr>
<td><input value="expTime" name="calcMethod" type="radio" /></td>
<td>Imaging integration time to achieve a S/N ratio of
<input name="sigmaD" size="3" value="5" type="text" />
<input name="coaddsD" value="1" type="hidden"/>
<input name="fracOnSourceD" value="1" type="hidden"/>
</td>
</tr>
<tr>
<td><input value="intTimeSpec" name="calcMethod" type="radio" /></td>
<td>Spectroscopy integration time to achieve a S/N ratio of
<input name="sigmaE" size="3" value="5" type="text" />
measured at <input name="wavelengthE" size="3" value="2200" type="text" /> nm.
<input name="coaddsE" value="1" type="hidden"/>
<input name="fracOnSourceE" value="1" type="hidden"/>
</td>
</tr>

<tr>
<td colspan="2" height="40" valign="bottom"><b>Telescope offset:</b><i><span>(<a href="#" onclick="window.open('http://www.gemini.edu/sciops/instruments/gnirs/spectroscopy/observing-strategies#offsetting','mywindow','width=1000,height=700,toolbar=no,location=no,directories=no,sta tus=no,menubar=no,scrollbars=yes,copyhistory=no,resizable=no'); return false">more info</a>)</span></i></td>
</tr>
Expand Down
Loading
Loading