Skip to content

Commit

Permalink
Merge pull request #1795 from swalker2m/ghost_seq_updates
Browse files Browse the repository at this point in the history
Ghost Exposure Time / Count Sequence Update
  • Loading branch information
cquiroz authored May 28, 2020
2 parents 554a69b + bd54b41 commit 075aafd
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,19 @@
import java.util.Map;

final public class SeqConfigGhost extends SeqConfigObsBase implements PropertyProvider {
public static final SPComponentType SP_TYPE = SPComponentType.ITERATOR_GHOST;

public static final SPComponentType SP_TYPE =
SPComponentType.ITERATOR_GHOST;

public static final ISPNodeInitializer<ISPSeqComponent, SeqConfigGhost> NI =
new ComponentNodeInitializer<>(SP_TYPE, SeqConfigGhost::new, SeqConfigGhostCB::new);
new ComponentNodeInitializer<>(SP_TYPE, SeqConfigGhost::new, SeqConfigGhostCB::new);

public static final String SYSTEM_NAME = SeqConfigNames.INSTRUMENT_CONFIG_NAME;

public static final Map<String, PropertyDescriptor> PROPERTY_MAP =
Collections.unmodifiableMap(
PropertySupport.filter(PropertyFilter.ITERABLE_FILTER, Ghost$.MODULE$.PropertyMap())
);
Collections.unmodifiableMap(
PropertySupport.filter(PropertyFilter.ITERABLE_FILTER, Ghost$.MODULE$.PropertyMap())
);

public SeqConfigGhost() {
super(SP_TYPE, SYSTEM_NAME);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,31 @@

import edu.gemini.pot.sp.ISPSeqComponent;
import edu.gemini.spModel.config.HelperSeqCompCB;
import edu.gemini.spModel.data.config.DefaultParameter;
import edu.gemini.spModel.data.config.IConfig;
import edu.gemini.spModel.data.config.StringParameter;
import edu.gemini.spModel.gemini.gmos.InstGmosSouth;
import edu.gemini.spModel.obscomp.InstConstants;
import edu.gemini.spModel.seqcomp.SeqConfigNames;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;

final public class SeqConfigGhostCB extends HelperSeqCompCB {
private static final long serialVersionUID = 1L;

private static final List<String> EXP_PROPS =
Collections.unmodifiableList(
Arrays.asList(
Ghost$.MODULE$.BLUE_EXPOSURE_COUNT_PROP().getName(),
Ghost$.MODULE$.BLUE_EXPOSURE_TIME_PROP().getName(),
Ghost$.MODULE$.RED_EXPOSURE_COUNT_PROP().getName(),
Ghost$.MODULE$.RED_EXPOSURE_TIME_PROP().getName()
)
);

public SeqConfigGhostCB(final ISPSeqComponent seqComp) {
super(seqComp);
}
Expand All @@ -28,7 +42,23 @@ protected void thisApplyNext(final IConfig config, final IConfig prevFull) {

config.putParameter(SeqConfigNames.INSTRUMENT_CONFIG_NAME,
StringParameter.getInstance(InstConstants.INSTRUMENT_NAME_PROP,
InstGmosSouth.INSTRUMENT_NAME_PROP));
Ghost$.MODULE$.INSTRUMENT_NAME_PROP()));

// A small hack to swap these to the "observe" system to be consistent
// everywhere.
for (String propName : EXP_PROPS) {
final Object o = config.getParameterValue(
SeqConfigNames.INSTRUMENT_CONFIG_NAME,
propName
);
config.removeParameter(SeqConfigNames.INSTRUMENT_CONFIG_NAME, propName);
if (o != null) {
config.putParameter(
SeqConfigNames.OBSERVE_CONFIG_NAME,
DefaultParameter.getInstance(propName, o)
);
}
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* The difference here is that GHOST does not have a single exposure time, but due to having two detectors - a red
* and a blue - exposure times and exposure counts for each. Additionally, GHOST does not have coadds.
*/
public class GhostSeqRepeatExp extends SeqRepeat implements Serializable {
public abstract class GhostSeqRepeatExp extends SeqRepeat implements Serializable {
private static final long serialVersionUID = 1L;

private double redExposureTime = InstConstants.DEF_EXPOSURE_TIME;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,18 +97,20 @@ final class Ghost extends SPInstObsComp(GhostMixin.SP_TYPE) with PropertyProvide
}

override def getSysConfig: ISysConfig = {
// Red/Blue exposure time parameters are added in the "observe" system.
// sc.putParameter(DefaultParameter.getInstance(Ghost.RED_EXPOSURE_TIME_PROP.getName, getRedExposureTime))
// sc.putParameter(DefaultParameter.getInstance(Ghost.RED_EXPOSURE_COUNT_PROP.getName, getRedExposureCount))
// sc.putParameter(DefaultParameter.getInstance(Ghost.BLUE_EXPOSURE_TIME_PROP.getName, getBlueExposureTime))
// sc.putParameter(DefaultParameter.getInstance(Ghost.BLUE_EXPOSURE_COUNT_PROP.getName, getBlueExposureCount))

val sc = new DefaultSysConfig(SeqConfigNames.INSTRUMENT_CONFIG_NAME)
sc.putParameter(StringParameter.getInstance(ISPDataObject.VERSION_PROP, getVersion))
sc.putParameter(DefaultParameter.getInstance(Ghost.POS_ANGLE_PROP, getPosAngle))
sc.putParameter(DefaultParameter.getInstance(Ghost.PORT_PROP, getIssPort))
sc.putParameter(DefaultParameter.getInstance(Ghost.ENABLE_FIBER_AGITATOR_1_PROP.getName, isEnableFiberAgitator1))
sc.putParameter(DefaultParameter.getInstance(Ghost.ENABLE_FIBER_AGITATOR_2_PROP.getName, isEnableFiberAgitator2))
sc.putParameter(DefaultParameter.getInstance(Ghost.RED_EXPOSURE_TIME_PROP.getName, getRedExposureTime))
sc.putParameter(DefaultParameter.getInstance(Ghost.RED_EXPOSURE_COUNT_PROP.getName, getRedExposureCount))
sc.putParameter(DefaultParameter.getInstance(Ghost.RED_BINNING_PROP.getName, getRedBinning))
sc.putParameter(DefaultParameter.getInstance(Ghost.RED_READ_NOISE_GAIN_PROP, getRedReadNoiseGain))
sc.putParameter(DefaultParameter.getInstance(Ghost.BLUE_EXPOSURE_TIME_PROP.getName, getBlueExposureTime))
sc.putParameter(DefaultParameter.getInstance(Ghost.BLUE_EXPOSURE_COUNT_PROP.getName, getBlueExposureCount))
sc.putParameter(DefaultParameter.getInstance(Ghost.BLUE_BINNING_PROP.getName, getBlueBinning))
sc.putParameter(DefaultParameter.getInstance(Ghost.BLUE_READ_NOISE_GAIN_PROP, getBlueReadNoiseGain))
sc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import edu.gemini.spModel.config.AbstractObsComponentCB
import edu.gemini.spModel.data.config._
import edu.gemini.spModel.gemini.ghost.GhostAsterism.GhostTarget
import edu.gemini.spModel.obscomp.InstConstants
import edu.gemini.spModel.seqcomp.SeqConfigNames.OBSERVE_CONFIG_NAME
import edu.gemini.spModel.target.obsComp.TargetObsComp
import edu.gemini.spModel.target.{SPCoordinates, SPSkyObject, SPTarget}

Expand All @@ -20,7 +21,9 @@ import scalaz._
* Configuration builder for GHOST.
*/
final class GhostCB(obsComp: ISPObsComponent) extends AbstractObsComponentCB(obsComp) {

@transient private var sysConfig: Option[ISysConfig] = None
@transient private var expConfig: Option[GhostCB.Exposure] = None

override def clone(): AnyRef = {
val result = super.clone().asInstanceOf[GhostCB]
Expand All @@ -33,13 +36,30 @@ final class GhostCB(obsComp: ISPObsComponent) extends AbstractObsComponentCB(obs
if (dataObj == null)
throw new IllegalArgumentException("The data object for GHOST cannot be null")
sysConfig = Some(dataObj.getSysConfig)
expConfig = Some(GhostCB.Exposure(dataObj))
}

override protected def thisHasConfiguration(): Boolean = {
sysConfig.exists(_.getParameterCount > 0)
sysConfig.exists(_.getParameterCount > 0) || expConfig.isDefined
}

override protected def thisApplyNext(config: IConfig, prevFull: IConfig): Unit = {
expConfig.foreach { ec =>

config.putParameter(OBSERVE_CONFIG_NAME,
DefaultParameter.getInstance(Ghost.RED_EXPOSURE_COUNT_PROP, ec.redCount))

config.putParameter(OBSERVE_CONFIG_NAME,
DefaultParameter.getInstance(Ghost.RED_EXPOSURE_TIME_PROP, ec.redTime))

config.putParameter(OBSERVE_CONFIG_NAME,
DefaultParameter.getInstance(Ghost.BLUE_EXPOSURE_COUNT_PROP, ec.blueCount))

config.putParameter(OBSERVE_CONFIG_NAME,
DefaultParameter.getInstance(Ghost.BLUE_EXPOSURE_TIME_PROP, ec.blueTime))

}

sysConfig.foreach { sc =>
val systemName: String = sc.getSystemName
sc.getParameters.asScala.foreach { p =>
Expand Down Expand Up @@ -157,3 +177,26 @@ final class GhostCB(obsComp: ISPObsComponent) extends AbstractObsComponentCB(obs
}
}
}

object GhostCB {

// Exposure parameters handled separately to place them in the "observe"
// system.
final case class Exposure(
redCount: Int,
redTime: Double,
blueCount: Int,
blueTime: Double
)

object Exposure {
def apply(g: Ghost): Exposure =
Exposure(
g.getRedExposureCount,
g.getRedExposureTime,
g.getBlueExposureCount,
g.getBlueExposureTime
)
}

}

0 comments on commit 075aafd

Please sign in to comment.