Search in sources :

Example 1 with ObservationSetting

use of fr.jmmc.aspro.model.oi.ObservationSetting in project aspro by JMMC-OpenDev.

the class UVCoveragePanel method getDefaultFileName.

/**
 * Return the default file name
 * @param fileExtension  document's file extension
 * @return default file name
 */
@Override
public String getDefaultFileName(final String fileExtension) {
    if (this.getChartData() != null) {
        final ObservationSetting observation = this.getChartData().getFirstObservation();
        final StringBuilder sb = new StringBuilder(32);
        sb.append("UV_");
        sb.append(StringUtils.replaceNonAlphaNumericCharsByUnderscore(this.getChartData().getTargetName())).append('_');
        sb.append(observation.getInstrumentConfiguration().getName()).append('_');
        sb.append(this.getChartData().getDisplayConfigurations("_", true));
        if (observation.getWhen().isNightRestriction()) {
            sb.append('_');
            sb.append(observation.getWhen().getDate().toString());
        }
        sb.append('.').append(fileExtension);
        return sb.toString();
    }
    return null;
}
Also used : ObservationSetting(fr.jmmc.aspro.model.oi.ObservationSetting)

Example 2 with ObservationSetting

use of fr.jmmc.aspro.model.oi.ObservationSetting in project aspro by JMMC-OpenDev.

the class UVCoveragePanel method performOBAction.

// </editor-fold>//GEN-END:initComponents
/**
 * Export Observing Block(s) (OB)
 * @param evt action event
 * @param mode export OB mode
 * @param xml true to use new OB output
 */
public void performOBAction(final ActionEvent evt, final ExportOBMode mode, final boolean xml) {
    // Use main observation to check instrument :
    final ObservationSetting observation = om.getMainObservation();
    if (!observation.isSingle()) {
        MessagePane.showMessage("Aspro 2 can not generate an Observing Block when multiple configurations are selected !");
        return;
    }
    if (xml) {
        switch(mode) {
            case ALL:
                ExportOBXmlAction.getInstance().process(observation.getTargets());
                break;
            case SINGLE:
                final Target target = getSelectedTarget();
                if (target != null) {
                    ExportOBXmlAction.getInstance().process(Arrays.asList(new Target[] { target }));
                }
                break;
            default:
        }
    } else {
        // PoP up to indicate OBX export is deprecated:
        DismissableMessagePane.show("Please consider using the a2p2 software instead" + "\nas this export feature is deprecated and will be removed soon (Fall 2019)\n\nSee https://github.com/JMMC-OpenDev/a2p2", Preferences.getInstance(), "DEPRECATED_OBX_WARNING");
        final String insName = observation.getInstrumentConfiguration().getName();
        if (AsproConstants.INS_AMBER.equals(insName) || AsproConstants.INS_MIDI.equals(insName) || insName.startsWith(AsproConstants.INS_PIONIER) || insName.startsWith(AsproConstants.INS_GRAVITY)) {
            switch(mode) {
                case ALL:
                    ExportOBVLTIAction.getInstance().process(observation.getTargets());
                    break;
                case SINGLE:
                    final Target target = getSelectedTarget();
                    if (target != null) {
                        ExportOBVLTIAction.getInstance().process(Arrays.asList(new Target[] { target }));
                    }
                    break;
                default:
            }
        } else if (insName.startsWith(AsproConstants.INS_VEGA)) {
            ExportOBVegaAction.getInstance().process();
        } else {
            MessagePane.showMessage("Aspro 2 can not generate an Observing Block for this instrument [" + insName + "] !");
        }
    }
}
Also used : Target(fr.jmmc.aspro.model.oi.Target) ObservationSetting(fr.jmmc.aspro.model.oi.ObservationSetting)

Example 3 with ObservationSetting

use of fr.jmmc.aspro.model.oi.ObservationSetting in project aspro by JMMC-OpenDev.

the class BasicObservationForm method updateObservabilityData.

/**
 * Update the observability Data
 * @param obsCollection observation collection to use
 * @param obsDataList observability data
 */
private void updateObservabilityData(final ObservationCollection obsCollection, final List<ObservabilityData> obsDataList) {
    // are PoPs in use ?
    if (!jComboBoxPops.isVisible()) {
        resetComboBoxPops(POPS_AUTO);
    } else {
        // reset
        this.popsCurrentMap = null;
        this.jButtonPopsSet.setToolTipText(null);
        this.jTextFieldCurrentPops.setText(null);
        final int nObs = obsDataList.size();
        if (nObs == 1) {
            final ObservationSetting observation = obsCollection.getFirstObservation();
            final ObservabilityData obsData = obsDataList.get(0);
            final String insConfKey = observation.getInstrumentConfiguration().getStations() + "@" + obsData.isDoBaseLineLimits();
            logger.debug("updateObservabilityData: used PoPs = {}", obsData.getUsedPops());
            if (obsData.getUsedPops() != null) {
                // Update current Pops:
                final List<Station> stations = obsData.getStationList();
                final Pop[] pops = obsData.getUsedPops().getPops();
                final Map<String, Pop> currentPops = new TreeMap<>();
                for (int i = 0; i < pops.length; i++) {
                    currentPops.put(stations.get(i).getName(), pops[i]);
                }
                this.popsCurrentMap = currentPops;
                logger.debug("popsCurrentMap: {}", popsCurrentMap);
                final StringBuilder sb = new StringBuilder(32);
                obsData.getStationNameWithPops(sb);
                this.jButtonPopsSet.setToolTipText("Set fixed Pops with " + sb.toString());
                if (lastStationsForPops != null) {
                    // Custom format:
                    sb.setLength(0);
                    sb.append(' ');
                    for (String name : lastStationsForPops) {
                        sb.append(name);
                        sb.append('(');
                        final Pop p = currentPops.get(name);
                        if (p != null) {
                            sb.append(p.getIndex());
                        } else {
                            sb.append('-');
                        }
                        sb.append(") ");
                    }
                    sb.deleteCharAt(sb.length() - 1);
                    this.jTextFieldCurrentPops.setText(sb.toString());
                }
            }
            final List<PopCombination> bestPopList = obsData.getBestPopList();
            final List<PopCombination> betterPopList = obsData.getBetterPopList();
            // PoPs list are null if [Manual]:
            if (bestPopList != null && betterPopList != null) {
                final Vector<String> orderedPops = new Vector<String>(bestPopList.size() + betterPopList.size() + 2);
                orderedPops.add(POPS_MANUAL);
                orderedPops.add(POPS_AUTO);
                for (PopCombination p : bestPopList) {
                    orderedPops.add(p.toString());
                }
                for (PopCombination p : betterPopList) {
                    orderedPops.add(p.toString());
                }
                // single observation results:
                final ComboBoxModel<String> comboPopsModel = new DefaultComboBoxModel<>(orderedPops);
                comboPopsModel.setSelectedItem(POPS_AUTO);
                jComboBoxPops.setModel(comboPopsModel);
                lastInsConfKeyForBestPops = insConfKey;
            } else {
                // check [Manual] ie is Pops combo box still valid ? (same stations)
                if ((lastInsConfKeyForBestPops != null) && !lastInsConfKeyForBestPops.equals(insConfKey)) {
                    resetComboBoxPops((obsData.isUserPops() ? POPS_MANUAL : POPS_AUTO));
                    lastInsConfKeyForBestPops = null;
                }
            }
        } else if (nObs > 1) {
            // multiple observation results but how to merge best PoPs solutions ?
            // reset and restore auto or manual mode:
            resetComboBoxPops((obsDataList.get(0).getBestPopList() != null) ? POPS_AUTO : POPS_MANUAL);
            lastInsConfKeyForBestPops = null;
        }
    }
}
Also used : ObservationSetting(fr.jmmc.aspro.model.oi.ObservationSetting) ObservabilityData(fr.jmmc.aspro.model.observability.ObservabilityData) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel) TreeMap(java.util.TreeMap) Point(java.awt.Point) PopCombination(fr.jmmc.aspro.model.observability.PopCombination) Station(fr.jmmc.aspro.model.oi.Station) Pop(fr.jmmc.aspro.model.oi.Pop) Vector(java.util.Vector)

Example 4 with ObservationSetting

use of fr.jmmc.aspro.model.oi.ObservationSetting in project aspro by JMMC-OpenDev.

the class BasicObservationForm method jButtonSkyCalcActionPerformed.

// </editor-fold>//GEN-END:initComponents
private void jButtonSkyCalcActionPerformed(java.awt.event.ActionEvent evt) {
    // GEN-FIRST:event_jButtonSkyCalcActionPerformed
    final Target selectedTarget = getSelectedTarget();
    if (selectedTarget != null) {
        final ObservationSetting observation = om.getMainObservation();
        final InterferometerDescription interferometer = observation.getInterferometerConfiguration().getInterferometerConfiguration().getInterferometer();
        final Site site = AstroSkyCalc.createSite(interferometer.getName(), interferometer.getPosSph());
        final List<Target> displayTargets = om.getDisplayTargets();
        final int size = displayTargets.size();
        final String[] name = new String[size];
        final String[] ra = new String[size];
        final String[] dec = new String[size];
        for (int i = 0; i < size; i++) {
            final Target target = displayTargets.get(i);
            name[i] = target.getName();
            // convert RA/DEC in HH:MM:SS.sss or DD:MM:SS.sss :
            final String[] raDec = AstroSkyCalcObservation.toString(target.getRADeg(), target.getDECDeg());
            ra[i] = raDec[0];
            dec[i] = raDec[1];
        }
        JSkyCalc.showJSkyCalc(site, name, ra, dec, selectedTarget.getName(), observation.getWhen().getDate());
    }
}
Also used : Site(edu.dartmouth.Site) Target(fr.jmmc.aspro.model.oi.Target) ObservationSetting(fr.jmmc.aspro.model.oi.ObservationSetting) Point(java.awt.Point) InterferometerDescription(fr.jmmc.aspro.model.oi.InterferometerDescription)

Example 5 with ObservationSetting

use of fr.jmmc.aspro.model.oi.ObservationSetting in project aspro by JMMC-OpenDev.

the class ObservabilityPanel method getDefaultFileName.

/**
 * Return the default file name
 * @param fileExtension  document's file extension
 * @return default file name
 */
@Override
public String getDefaultFileName(final String fileExtension) {
    if (this.getChartData() != null) {
        final ObservationSetting observation = this.getChartData().getFirstObservation();
        // flags used by the plot :
        final ObservabilityData obsData = this.getChartData().getFirstObsData();
        final boolean doBaseLineLimits = obsData.isDoBaseLineLimits();
        final boolean doDetailedOutput = obsData.isDoDetailedOutput();
        final StringBuilder sb = new StringBuilder(32);
        sb.append("OBS_");
        final String baseLine = this.getChartData().getDisplayConfigurations("_", true);
        if (doBaseLineLimits) {
            sb.append("LIMITS_");
            sb.append(this.getChartData().getInterferometerConfiguration(true));
            sb.append('_').append(baseLine);
        } else {
            if (doDetailedOutput) {
                sb.append("DETAILS_");
            }
            sb.append(observation.getInstrumentConfiguration().getName());
            sb.append('_').append(baseLine);
            if (observation.getWhen().isNightRestriction()) {
                sb.append('_');
                sb.append(observation.getWhen().getDate().toString());
            }
        }
        sb.append('.').append(fileExtension);
        return sb.toString();
    }
    return null;
}
Also used : ObservationSetting(fr.jmmc.aspro.model.oi.ObservationSetting) ObservabilityData(fr.jmmc.aspro.model.observability.ObservabilityData) StarObservabilityData(fr.jmmc.aspro.model.observability.StarObservabilityData)

Aggregations

ObservationSetting (fr.jmmc.aspro.model.oi.ObservationSetting)48 Target (fr.jmmc.aspro.model.oi.Target)14 IOException (java.io.IOException)9 File (java.io.File)8 ObservabilityData (fr.jmmc.aspro.model.observability.ObservabilityData)6 FocalInstrumentConfigurationChoice (fr.jmmc.aspro.model.oi.FocalInstrumentConfigurationChoice)5 ObservationManager (fr.jmmc.aspro.model.ObservationManager)4 FocalInstrumentMode (fr.jmmc.aspro.model.oi.FocalInstrumentMode)4 TargetUserInformations (fr.jmmc.aspro.model.oi.TargetUserInformations)4 ObservabilityService (fr.jmmc.aspro.service.ObservabilityService)4 StarObservabilityData (fr.jmmc.aspro.model.observability.StarObservabilityData)3 TargetRawObservation (fr.jmmc.aspro.model.oi.TargetRawObservation)3 TargetEditorDialog (fr.jmmc.aspro.gui.TargetEditorDialog)2 TargetSelectionEvent (fr.jmmc.aspro.model.event.TargetSelectionEvent)2 UpdateObservationEvent (fr.jmmc.aspro.model.event.UpdateObservationEvent)2 BaseValue (fr.jmmc.aspro.model.oi.BaseValue)2 ObservationCollection (fr.jmmc.aspro.model.oi.ObservationCollection)2 ObservationVariant (fr.jmmc.aspro.model.oi.ObservationVariant)2 SpectralBand (fr.jmmc.aspro.model.oi.SpectralBand)2 Station (fr.jmmc.aspro.model.oi.Station)2