Skip to content

Commit

Permalink
Merge pull request #65 from LCOGT/feature/update-default-calib-exptimes
Browse files Browse the repository at this point in the history
Feature/update default calib exptimes
  • Loading branch information
jnation3406 committed Aug 7, 2019
2 parents df81357 + b0295fa commit 6dd7298
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 24 deletions.
24 changes: 19 additions & 5 deletions static/js/components/instrumentconfig.vue
Expand Up @@ -66,9 +66,15 @@
v-if="suggestedLampFlatSlitExposureTime"
>
Suggested exposure time for a Lamp Flat with
slit {{ instrumentconfig.optical_elements.slit }}
slit {{ instrumentconfig.optical_elements.slit }} and readout mode {{ instrumentconfig.mode }}
is <strong>{{ suggestedLampFlatSlitExposureTime }} seconds</strong>
</div>
</div>
<div
slot="extra-help-text"
v-else-if="suggestedArcExposureTime"
>
Suggested exposure time for an Arc is <strong>{{ suggestedArcExposureTime }} seconds</strong>
</div>
</customfield>
<customselect
v-if="readoutModeOptions.length > 1"
Expand Down Expand Up @@ -137,7 +143,7 @@
<script>
import _ from 'lodash';
import { collapseMixin, slitWidthToExposureTime } from '../utils.js';
import { collapseMixin, lampFlatDefaultExposureTime, arcDefaultExposureTime } from '../utils.js';
import customfield from './util/customfield.vue';
import customselect from './util/customselect.vue';
import panel from './util/panel.vue';
Expand Down Expand Up @@ -273,8 +279,16 @@ export default {
// Update on optical element updates
this.opticalElementUpdates;
let slitWidth = this.instrumentconfig.optical_elements.slit;
if (this.configurationType === 'LAMP_FLAT' && slitWidth) {
return slitWidthToExposureTime(slitWidth);
let readoutMode = this.instrumentconfig.mode;
if (this.configurationType === 'LAMP_FLAT' && slitWidth && readoutMode && this.selectedinstrument) {
return lampFlatDefaultExposureTime(slitWidth, this.selectedinstrument, readoutMode);
} else {
return undefined;
}
},
suggestedArcExposureTime: function() {
if (this.configurationType === 'ARC' && this.selectedinstrument) {
return arcDefaultExposureTime(this.selectedinstrument);
} else {
return undefined;
}
Expand Down
12 changes: 8 additions & 4 deletions static/js/components/request.vue
Expand Up @@ -93,7 +93,7 @@
<script>
import _ from 'lodash';
import { collapseMixin, slitWidthToExposureTime } from '../utils.js';
import { collapseMixin, arcDefaultExposureTime, lampFlatDefaultExposureTime } from '../utils.js';
import configuration from './configuration.vue';
import window from './window.vue';
import panel from './util/panel.vue';
Expand Down Expand Up @@ -251,21 +251,25 @@
for (let c in calibs) {
calibs[c] = _.cloneDeep(request.configurations[configuration_id]);
for (let ic in calibs[c].instrument_configs) {
calibs[c].instrument_configs[ic].exposure_time = 60;
calibs[c].instrument_configs[ic].exposure_time = arcDefaultExposureTime(this.instrument_type);
}
}
calibs[0].type = 'LAMP_FLAT'; calibs[1].type = 'ARC';
calibs[0].guiding_config.optional = true; calibs[1].guiding_config.optional = true;
calibs[0].guiding_config.mode = 'ON'; calibs[1].guiding_config.mode = 'ON';
for (let ic in calibs[0].instrument_configs) {
calibs[0].instrument_configs[ic].exposure_time = slitWidthToExposureTime(calibs[0].instrument_configs[ic].optical_elements.slit);
calibs[0].instrument_configs[ic].exposure_time = lampFlatDefaultExposureTime(
calibs[0].instrument_configs[ic].optical_elements.slit, this.instrument_type, calibs[0].instrument_configs[ic].mode
);
}
request.configurations.unshift(calibs[0], calibs[1]);
calibs[2].type = 'ARC'; calibs[3].type = 'LAMP_FLAT';
calibs[2].guiding_config.optional = true; calibs[3].guiding_config.optional = true;
calibs[2].guiding_config.mode = 'ON'; calibs[3].guiding_config.mode = 'ON';
for (let ic in calibs[3].instrument_configs) {
calibs[3].instrument_configs[ic].exposure_time = slitWidthToExposureTime(calibs[3].instrument_configs[ic].optical_elements.slit);
calibs[3].instrument_configs[ic].exposure_time = lampFlatDefaultExposureTime(
calibs[3].instrument_configs[ic].optical_elements.slit, this.instrument_type, calibs[3].instrument_configs[ic].mode
);
}
request.configurations.push(calibs[2], calibs[3]);
this.update();
Expand Down
53 changes: 38 additions & 15 deletions static/js/utils.js
Expand Up @@ -2,23 +2,46 @@ import moment from 'moment';
import _ from 'lodash';
import $ from 'jquery';

function slitWidthToExposureTime(slitWidth){

function isSoarInstrument(instrumentType) {
return _.toLower(instrumentType).includes('soar');
}

function lampFlatDefaultExposureTime(slitWidth, instrumentType, readoutMode) {
// Lamp flats are affected by the slit width, so exposure time needs to scale with it
if(slitWidth.includes('1.2')){
return 70;
}
else if(slitWidth.includes('1.6')){
return 50;
}
else if(slitWidth.includes('2.0')){
return 40;
}
else if(slitWidth.includes('6.0')){
return 15;
readoutMode = _.toLower(readoutMode);
slitWidth = _.toLower(slitWidth);
if (isSoarInstrument(instrumentType)) {
if (readoutMode.includes('400m1')) {
return 3;
} else if (readoutMode.includes('400m2')) {
return 2;
}
} else {
if (slitWidth.includes('1.2')) {
return 70;
}
else if (slitWidth.includes('1.6')) {
return 50;
}
else if (slitWidth.includes('2.0')) {
return 40;
}
else if (slitWidth.includes('6.0')) {
return 15;
}
}
return 60;
}

function arcDefaultExposureTime(instrumentType) {
if (isSoarInstrument(instrumentType)) {
return 0.5;
} else {
return 60;
}
}

function semesterStart(datetime){
if(datetime.month() < 3 ){
return datetime.subtract(1, 'years').month(9).date(1);
Expand Down Expand Up @@ -320,7 +343,7 @@ let colorPalette = [ // useful assigning colors to datasets.

export {
semesterStart, semesterEnd, sexagesimalRaToDecimal, sexagesimalDecToDecimal, QueryString, formatJson, formatValue,
formatDate, formatField, datetimeFormat, collapseMixin, siteToColor, siteCodeToName, slitWidthToExposureTime,
observatoryCodeToNumber, telescopeCodeToName, colorPalette, julianToModifiedJulian, getFieldDescription,
decimalRaToSexigesimal, decimalDecToSexigesimal, tooltipConfig, addCsrfProtection
formatDate, formatField, datetimeFormat, collapseMixin, siteToColor, siteCodeToName, arcDefaultExposureTime,
lampFlatDefaultExposureTime, observatoryCodeToNumber, telescopeCodeToName, colorPalette, julianToModifiedJulian,
getFieldDescription, decimalRaToSexigesimal, decimalDecToSexigesimal, tooltipConfig, addCsrfProtection
};

0 comments on commit 6dd7298

Please sign in to comment.