Skip to content

IRSA-540, IRSA-541:Add PTF case to Time Series Tool #409

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

Merged
merged 8 commits into from
Jul 18, 2017
Merged
Show file tree
Hide file tree
Changes from 4 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
105 changes: 78 additions & 27 deletions src/firefly/js/tables/TableUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -896,33 +896,6 @@ export function createErrorTbl(tbl_id, error) {
}


/**
* @summary get column names from the column of numeric type
* @param {Array} tblColumns
* @returns {Array}
*/
export function getNumericColNames(tblColumns) {
const NumTypes = ['double', 'd', 'long', 'l', 'int', 'i', 'float', 'f'];

return isEmpty(tblColumns) ? [] :
tblColumns.filter((tblCol) => (get(tblCol, 'visibility', '') !== 'hidden'))
.filter((tblCol) => (NumTypes.includes(tblCol.type)))
.map((tblCol) => (tblCol.name));
}

/**
* @summary get column names from the column of string or char type
* @param {Array} tblColumns
* @returns {Array}
*/
export function getStringColNames(tblColumns) {
const CharTypes = ['char', 'c', 's', 'str'];

return isEmpty(tblColumns) ? [] :
tblColumns.filter((tblCol) => (get(tblCol, 'visibility', '') !== 'hidden'))
.filter((tblCol) => (CharTypes.includes(tblCol.type)))
.map((tblCol) => (tblCol.name));
}

/**
* this function invoke the given callback when changes are made to the given tbl_id
Expand Down Expand Up @@ -984,3 +957,81 @@ function* doOnTblLoaded({tbl_id, callback}) {
}



/**
* Returns only numerical column names form raw lc table
* @param {Object} rawTbl
* @returns {string[]} - array of table columns objects
*/
export function getOnlyNumericalColNames(rawTbl) {
const cols = get(rawTbl, ['tableData', 'columns']);
const colType = getColumnTypes(cols, 'numeric');
return get(rawTbl, ['tableData', 'columns']).reduce((prev, col) => {
if ((colType.includes(col.type)) ) {
prev.push(col.name);
}
return prev;
}, []);
}


/**
* @summary get column names from the column of string or char type
* @param {Array} tblColumns
* @returns {Array}
*/
export function getStringColNames(tblColumns) {
const CharTypes = ['char', 'c', 's', 'str'];

return isEmpty(tblColumns) ? [] :
tblColumns.filter((tblCol) => (get(tblCol, 'visibility', '') !== 'hidden'))
.filter((tblCol) => (CharTypes.includes(tblCol.type)))
.map((tblCol) => (tblCol.name));
}

/**
* @summary get column names from the column of numeric type
* @param {Array} tblColumns
* @returns {Array}
*/
export function getNumericColNames(tblColumns) {
const NumTypes = ['double', 'd', 'long', 'l', 'int', 'i', 'float', 'f'];

return isEmpty(tblColumns) ? [] :
tblColumns.filter((tblCol) => (get(tblCol, 'visibility', '') !== 'hidden'))
.filter((tblCol) => (NumTypes.includes(tblCol.type)))
.map((tblCol) => (tblCol.name));
}

export function getColNames(tblColumns, colTypes) {
return isEmpty(tblColumns)?[]:
tblColumns.reduce((prev, col) => {
if ( colTypes && colTypes.includes(col.type) ) {
prev.push(col.name);
}
else {
prev.push(col.name);
}
return prev;
}, []);
}

export function getColumnTypes (cols, type=undefined){
// const cols = get(tblModel, ['tableData', 'columns']);
var types =[];
for (let i=0; i<cols.length; i++){
if (types.indexOf(cols[i].type)>-1) continue;
if(!has(cols[i], 'visibility') || get(cols[i], 'visibility') !== 'hidden') {
if (!type || type === 'numeric') {
if (cols[i].type!=='char' && cols[i].type.toLowerCase()!=='string' ) {
types[i] = cols[i].type;
}
}
else {
types[i] = cols[i].type;
}
}
}
return types;

}
1 change: 0 additions & 1 deletion src/firefly/js/templates/hydra/HydraManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {deleteAllDrawLayers} from '../../visualize/PlotViewUtil.js';
import {CHART_ADD} from '../../charts/ChartsCntlr.js';
import {REPLACE_VIEWER_ITEMS} from '../../visualize/MultiViewCntlr.js';


/**
* Configurable part of this template
* @typedef {object} Config
Expand Down
33 changes: 27 additions & 6 deletions src/firefly/js/templates/lightcurve/LcConverterFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@
import {get, isNil} from 'lodash';
import {TitleOptions} from '../../visualize/WebPlotRequest.js';
import {logError} from '../../util/WebUtil.js';
import {getWebPlotRequestViaPTFIbe} from './ptf/PTFPlotRequests.js';
import {getWebPlotRequestViaWISEIbe} from './wise/WisePlotRequests.js';
import {makeLsstSdssPlotRequest} from './lsst_sdss/LsstSdssPlotRequests.js';
import {makeURLPlotRequest} from './generic/DefaultPlotRequests.js';
import {basicURLPlotRequest} from './basic/BasicPlotRequests';
import {LsstSdssSettingBox, lsstSdssOnNewRawTable, lsstSdssOnFieldUpdate, lsstSdssRawTableRequest} from './lsst_sdss/LsstSdssMissionOptions.js';
import {WiseSettingBox, wiseOnNewRawTable, wiseOnFieldUpdate, wiseRawTableRequest, isBasicTableUploadValid} from './wise/WiseMissionOptions.js';
import {DefaultSettingBox, defaultOnNewRawTable, defaultOnFieldUpdate, defaultRawTableRequest} from './generic/DefaultMissionOptions.js';
import {BasicSettingBox, basicOnNewRawTable, basicOnFieldUpdate, basicRawTableRequest, imagesShouldBeDisplayed} from './basic/BasicMissionOptions.js';
import {WiseSettingBox, wiseOnNewRawTable, wiseOnFieldUpdate, wiseRawTableRequest,isValidWiseTable} from './wise/WiseMissionOptions.js';
import {PTFSettingBox, ptfOnNewRawTable, ptfOnFieldUpdate, ptfRawTableRequest,isValidPTFTable} from './ptf/PTFMissionOptions.js';

import {LC} from './LcManager.js';

export const UNKNOWN_MISSION = 'generic';
Expand All @@ -21,7 +24,6 @@ export const coordSysOptions = 'coordSysOptions';
/**
* A function to create a WebPlotRequest from the given parameters
* @callback WebplotRequestCreator
* @param {TableModel} tableModel
* @param {number} hlrow
* @param {number} cutoutSize
* @param {Object} params - mission specific parameters
Expand Down Expand Up @@ -91,7 +93,7 @@ const converters = {
dataSource: 'frame_id',
webplotRequestCreator: getWebPlotRequestViaWISEIbe,
shouldImagesBeDisplayed: () => {return true;},
isTableUploadValid: isBasicTableUploadValid,
isTableUploadValid: isValidWiseTable,
yNamesChangeImage: [],
showPlotTitle:getPlotTitle
},
Expand All @@ -111,9 +113,28 @@ const converters = {
yErrNames: ['magErr', 'tsv_fluxErr'],
webplotRequestCreator: makeLsstSdssPlotRequest,
shouldImagesBeDisplayed: () => {return true;},
isTableUploadValid: () => {return true;},
isTableUploadValid: () => {return {errorMsg:undefined, isValid:true};},
yNamesChangeImage: []
},
'ptf': {
converterId: 'ptf',
defaultImageCount: 5,
defaultTimeCName: 'obsmjd',
defaultYCname: 'mag_autocorr',
defaultYErrCname: '',
missionName: 'PTF',
MissionOptions: PTFSettingBox,
onNewRawTable: ptfOnNewRawTable,
onFieldUpdate: ptfOnFieldUpdate,
rawTableRequest: wiseRawTableRequest, //the r
yErrNames: '',
dataSource: 'pid',
webplotRequestCreator: getWebPlotRequestViaPTFIbe,
shouldImagesBeDisplayed: () => {return true;},
isTableUploadValid:isValidPTFTable,
yNamesChangeImage: [],
showPlotTitle:getPlotTitle
},
[UNKNOWN_MISSION]: {
converterId: UNKNOWN_MISSION,
defaultImageCount: 3,
Expand All @@ -132,7 +153,7 @@ const converters = {
[coordSysOptions]: COORD_SYSTEM_OPTIONS,
webplotRequestCreator: makeURLPlotRequest,
shouldImagesBeDisplayed: () => {return true;},
isTableUploadValid: () => {return true;},
isTableUploadValid: () => {return {errorMsg:undefined, isValid:true};},
yNamesChangeImage: [], // TODO: y columns which will affect the image display
noImageCutout: true // no image cutout is used
},
Expand All @@ -155,7 +176,7 @@ const converters = {
[coordSysOptions]: COORD_SYSTEM_OPTIONS,
webplotRequestCreator: basicURLPlotRequest,
shouldImagesBeDisplayed: imagesShouldBeDisplayed,
isTableUploadValid: () => {return true;},
isTableUploadValid: () => {return {errorMsg:undefined, isValid:true}; },
yNamesChangeImage: [],
showPlotTitle:getPlotTitle
}
Expand Down
6 changes: 2 additions & 4 deletions src/firefly/js/templates/lightcurve/LcManager.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
/*
* License information at https://github.com/Caltech-IPAC/firefly/blob/master/License.txt
*/
import {get, has, isEmpty, isNil, set, cloneDeep, defer} from 'lodash';
import {get, has, isEmpty, isNil, cloneDeep, defer} from 'lodash';
import {take, fork} from 'redux-saga/effects';
import {SHOW_DROPDOWN, SET_LAYOUT_MODE, getLayouInfo,
dispatchUpdateLayoutInfo, dropDownManager} from '../../core/LayoutCntlr.js';
import {TBL_RESULTS_ADDED, TABLE_LOADED, TBL_RESULTS_ACTIVE, TABLE_HIGHLIGHT, TABLE_SEARCH, TABLE_FETCH,
dispatchTableRemove, dispatchTableHighlight, dispatchTableFetch, dispatchTableSort} from '../../tables/TablesCntlr.js';
import {getCellValue, getTblById, getTblIdsByGroup, getActiveTableId, smartMerge, getColumnIdx, removeTablesFromGroup} from '../../tables/TableUtil.js';
import {dispatchTableReplace} from '../../tables/TablesCntlr.js';
import {updateSet, updateMerge, logError} from '../../util/WebUtil.js';
import ImagePlotCntlr, {dispatchPlotImage, visRoot, dispatchDeletePlotView,
dispatchChangeActivePlotView,
Expand All @@ -25,8 +24,6 @@ import {getConverter} from './LcConverterFactory.js';
import {sortInfoString} from '../../tables/SortInfo.js';
import {makeMissionEntries, keepHighlightedRowSynced} from './LcUtil.jsx';
import {dispatchMountFieldGroup} from '../../fieldGroup/FieldGroupCntlr.js';
import {ServerParams} from '../../data/ServerParams.js';
import {convertAngle} from '../../visualize/VisUtil.js';



Expand Down Expand Up @@ -466,6 +463,7 @@ function handleRawTableLoad(layoutInfo, tblId) {
return;
}

//TODO LZ How validTable is used, the onNewRawtable has its value to false. But it was never used here???
let {newLayoutInfo, shouldContinue, validTable} = converterData.onNewRawTable(rawTable, missionEntries, generalEntries, converterData, layoutInfo);
const newMissionEntries = get(newLayoutInfo, ['missionEntries']); // missionEntries could have changed after calling specific mission onRaw
newLayoutInfo = updateSet(newLayoutInfo, 'rawTableColumns', get(rawTable, ['tableData', 'columns']));
Expand Down
Loading