From 00d0cf8e3f8d8eef757ccb4b361ea013812dd955 Mon Sep 17 00:00:00 2001 From: Ricardo Valles Blanco Date: Thu, 14 Sep 2017 20:43:48 +0200 Subject: [PATCH 01/10] =?UTF-8?q?DAVE-288:=20Plots=20with=20custom=20binsi?= =?UTF-8?q?ze=20and=20multiple=20bug=20fixing=C3=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- setup/setup.bash | 14 +-- src/main/python/config.py | 3 + src/main/python/utils/dataset_helper.py | 2 +- src/main/python/utils/dave_endpoint.py | 24 ++-- src/main/python/utils/dave_engine.py | 57 +++++---- src/main/python/utils/dave_reader.py | 4 + src/main/resources/static/scripts/common.js | 21 +++- src/main/resources/static/scripts/config.js | 4 +- .../resources/static/scripts/master_page.js | 10 +- .../scripts/outputPanels/wfOutputPanel.js | 22 ++++ .../static/scripts/plots/covariancePlot.js | 16 +-- .../static/scripts/plots/dynSpPlot.js | 86 ++++++------- .../resources/static/scripts/plots/fitPlot.js | 5 + .../resources/static/scripts/plots/lcPlot.js | 10 +- .../resources/static/scripts/plots/pdsPlot.js | 70 +++++------ .../resources/static/scripts/plots/pgPlot.js | 4 +- .../resources/static/scripts/plots/plot.js | 29 ++++- .../static/scripts/plots/plotWithSettings.js | 113 +++++++++++++++--- .../resources/static/scripts/plots/rmsPlot.js | 19 ++- .../resources/static/scripts/projectConfig.js | 8 +- src/main/resources/static/scripts/schema.js | 2 +- .../static/scripts/selectors/binSelector.js | 54 ++++++++- .../scripts/selectors/sliderSelector.js | 15 ++- .../static/scripts/tabPanels/agnTabpanel.js | 4 + .../static/scripts/tabPanels/pgTabpanel.js | 9 +- .../static/scripts/tabPanels/phTabpanel.js | 9 +- .../scripts/tabPanels/settingsTabpanel.js | 1 + .../static/scripts/tabPanels/wfTabpanel.js | 1 + .../static/scripts/tabPanels/xsTabpanel.js | 4 + .../resources/static/scripts/toolpanel.js | 55 ++++----- .../resources/static/styles/master_page.css | 2 +- 31 files changed, 442 insertions(+), 235 deletions(-) diff --git a/setup/setup.bash b/setup/setup.bash index 2382678..4d69a1a 100755 --- a/setup/setup.bash +++ b/setup/setup.bash @@ -144,7 +144,7 @@ else if [[ retVal -ne 0 ]] ; then echo "Failed to create virtual Python environment." return 1 - + # We can try to fix it by deleting the pip cache but the case so far I've seen, deleting the pip cache doens't solve it. # echo "Failed to create virtual Python environment. Deleting pip cache and try again." # if [[ "$OSTYPE" == "linux-gnu" ]]; then @@ -161,7 +161,7 @@ else # return 1 # fi fi - + fi source activate dave @@ -169,8 +169,8 @@ source activate dave STINGRAY_FOLDER=$DIR/stingray STINGRAY_URL=https://github.com/StingraySoftware/stingray.git # Sets the specific commit to checkout: -# Sep 7th, 2017 -> https://github.com/StingraySoftware/stingray/commit/e833a5c4090641c84f16df64439b27af8356bbb2 -STINGRAY_COMMIT_HASH=e833a5c4090641c84f16df64439b27af8356bbb2 +# Sep 10th, 2017 -> https://github.com/StingraySoftware/stingray/commit/97094d49a8ff0a4e8392fde509116ba9f366a9f2 +STINGRAY_COMMIT_HASH=97094d49a8ff0a4e8392fde509116ba9f366a9f2 LINUX_COMPILATION=lib.linux-x86_64-3.5 DARWIN_COMPILATION=lib.macosx-10.5-x86_64-3.5 @@ -189,7 +189,7 @@ if [ ! -e $STINGRAY_FOLDER ]; then #Install stingray libraries echo statsmodels >> requirements.txt pip install -r requirements.txt - + retVal=$? if [[ retVal -ne 0 ]] ; then echo "Failed to install Stingray dependencies" @@ -237,8 +237,8 @@ fi HENDRICS_FOLDER=$DIR/hendrics HENDRICS_URL=https://github.com/StingraySoftware/HENDRICS.git # Sets the specific commit to checkout: -# Sep 4, 2017 -> https://github.com/StingraySoftware/HENDRICS/commit/a1757c0b21bd3aeb55bec22bc23d3c5440f7440c -HENDRICS_COMMIT_HASH=a1757c0b21bd3aeb55bec22bc23d3c5440f7440c +# Sep 9th, 2017 -> https://github.com/StingraySoftware/HENDRICS/commit/a5b7b7389b832b1eeaa87e6e470c659e454f490f +HENDRICS_COMMIT_HASH=a5b7b7389b832b1eeaa87e6e470c659e454f490f if [ ! -e $HENDRICS_FOLDER ]; then diff --git a/src/main/python/config.py b/src/main/python/config.py index a7b739a..5fa779a 100644 --- a/src/main/python/config.py +++ b/src/main/python/config.py @@ -10,17 +10,20 @@ class CONFIG: LOG_LEVEL = -1 # ALL = -1, DEBUG = 0, INFO = 1, WARN = 2, ERROR = 3, NONE = 4 USE_JAVASCRIPT_CACHE = False #If true, DAVE GUI will try to get js files from browser cache. Use False for development environments PYTHON_CACHE_SIZE = 32 # The maximun number of items to store in the LRU cache + MAX_PLOT_POINTS = 1000 # The maximun number of elements to return in a JSON NDARRAY def set_config(config): CONFIG.IS_LOCAL_SERVER = config['IS_LOCAL_SERVER'] CONFIG.LOG_TO_SERVER_ENABLED = config['LOG_TO_SERVER_ENABLED'] CONFIG.LOG_LEVEL = int(config['LOG_LEVEL']) + CONFIG.MAX_PLOT_POINTS = int(config['MAX_PLOT_POINTS']) return "IS_LOCAL_SERVER: " + str(CONFIG.IS_LOCAL_SERVER) \ + ", DEBUG_MODE: " + str(CONFIG.DEBUG_MODE) \ + ", LOG_TO_SERVER_ENABLED: " + str(CONFIG.LOG_TO_SERVER_ENABLED) \ + ", LOG_LEVEL: " + str(CONFIG.LOG_LEVEL) \ + ", BIG_NUMBER: " + str(CONFIG.BIG_NUMBER) \ + + ", MAX_PLOT_POINTS: " + str(CONFIG.MAX_PLOT_POINTS) \ + ", PRECISSION: " + str(CONFIG.PRECISSION) \ + ", USE_JAVASCRIPT_CACHE: " + str(CONFIG.USE_JAVASCRIPT_CACHE) diff --git a/src/main/python/utils/dataset_helper.py b/src/main/python/utils/dataset_helper.py index f51a05d..1f26e27 100644 --- a/src/main/python/utils/dataset_helper.py +++ b/src/main/python/utils/dataset_helper.py @@ -376,10 +376,10 @@ def update_dataset_filtering_by_gti(hdu_table, gti_table, ev_list, ev_list_err, if ad_column in ds_columns_errors and len(ds_columns_errors[ad_column]) > end_event_idx: error_values=np.nan_to_num(ds_columns_errors[ad_column][start_event_idx:end_event_idx]) hdu_table.columns[ad_column].add_values(values, error_values) - else: logging.info("No data point in GTI # %s: GTI (from, to)=(%f, %f); event list (from, to)=(%d, %d)" % (gti_index, start, end, start_event_idx, end_event_idx)) + # Returns a tuple with the counts and the key values # of applying the histogram to an array # diff --git a/src/main/python/utils/dave_endpoint.py b/src/main/python/utils/dave_endpoint.py index 3f70490..5fd185e 100644 --- a/src/main/python/utils/dave_endpoint.py +++ b/src/main/python/utils/dave_endpoint.py @@ -196,7 +196,7 @@ def get_lightcurve(src_filename, bck_filename, gti_filename, target, filters, ax logging.debug("get_lightcurve gti: %s" % gti_filename) logging.debug("get_lightcurve: filters %s" % filters) logging.debug("get_lightcurve: axis %s" % axis) - logging.debug("get_lightcurve: dt %f" % dt) + logging.debug("get_lightcurve: dt %s" % dt) logging.debug("get_lightcurve: baseline_opts %s" % baseline_opts) logging.debug("get_lightcurve: variance_opts %s" % variance_opts) @@ -236,7 +236,7 @@ def get_joined_lightcurves(lc0_filename, lc1_filename, lc0_bck_filename, lc1_bck logging.debug("get_joined_lightcurves lc1_bck: %s" % lc1_bck_filename) logging.debug("get_joined_lightcurves: filters %s" % filters) logging.debug("get_joined_lightcurves: axis %s" % axis) - logging.debug("get_joined_lightcurves: dt %f" % dt) + logging.debug("get_joined_lightcurves: dt %s" % dt) data = DaveEngine.get_joined_lightcurves(lc0_destination, lc1_destination, lc0_bck_destination, lc1_bck_destination, @@ -269,7 +269,7 @@ def get_divided_lightcurves_from_colors(src_filename, bck_filename, gti_filename logging.debug("get_divided_lightcurves_from_colors gti: %s" % gti_filename) logging.debug("get_divided_lightcurves_from_colors: filters %s" % filters) logging.debug("get_divided_lightcurves_from_colors: axis %s" % axis) - logging.debug("get_divided_lightcurves_from_colors: dt %f" % dt) + logging.debug("get_divided_lightcurves_from_colors: dt %s" % dt) data = DaveEngine.get_divided_lightcurves_from_colors(src_destination, bck_destination, gti_destination, filters, axis, dt) @@ -335,7 +335,7 @@ def get_power_density_spectrum(src_filename, bck_filename, gti_filename, target, logging.debug("get_power_density_spectrum gti: %s" % gti_filename) logging.debug("get_power_density_spectrum: filters %s" % filters) logging.debug("get_power_density_spectrum: axis %s" % axis) - logging.debug("get_power_density_spectrum: dt %f" % dt) + logging.debug("get_power_density_spectrum: dt %s" % dt) logging.debug("get_power_density_spectrum: nsegm %f" % nsegm) logging.debug("get_power_density_spectrum: segm_size %f" % segm_size) logging.debug("get_power_density_spectrum: norm %s" % norm) @@ -372,7 +372,7 @@ def get_dynamical_spectrum(src_filename, bck_filename, gti_filename, target, logging.debug("get_dynamical_spectrum gti: %s" % gti_filename) logging.debug("get_dynamical_spectrum: filters %s" % filters) logging.debug("get_dynamical_spectrum: axis %s" % axis) - logging.debug("get_dynamical_spectrum: dt %f" % dt) + logging.debug("get_dynamical_spectrum: dt %s" % dt) logging.debug("get_dynamical_spectrum: nsegm %f" % nsegm) logging.debug("get_dynamical_spectrum: segm_size %f" % segm_size) logging.debug("get_dynamical_spectrum: norm %s" % norm) @@ -506,7 +506,7 @@ def get_phase_lag_spectrum(src_filename, bck_filename, gti_filename, target, logging.debug("get_phase_lag_spectrum gti: %s" % gti_filename) logging.debug("get_phase_lag_spectrum: filters %s" % filters) logging.debug("get_phase_lag_spectrum: axis %s" % axis) - logging.debug("get_phase_lag_spectrum: dt %f" % dt) + logging.debug("get_phase_lag_spectrum: dt %s" % dt) logging.debug("get_phase_lag_spectrum: nsegm %f" % nsegm) logging.debug("get_phase_lag_spectrum: segm_size %f" % segm_size) logging.debug("get_phase_lag_spectrum: norm %s" % norm) @@ -548,7 +548,7 @@ def get_rms_spectrum(src_filename, bck_filename, gti_filename, target, logging.debug("get_rms_spectrum gti: %s" % gti_filename) logging.debug("get_rms_spectrum: filters %s" % filters) logging.debug("get_rms_spectrum: axis %s" % axis) - logging.debug("get_rms_spectrum: dt %f" % dt) + logging.debug("get_rms_spectrum: dt %s" % dt) logging.debug("get_rms_spectrum: nsegm %f" % nsegm) logging.debug("get_rms_spectrum: segm_size %f" % segm_size) logging.debug("get_rms_spectrum: norm %s" % norm) @@ -602,7 +602,7 @@ def get_fit_powerspectrum_result(src_filename, bck_filename, gti_filename, targe logging.debug("get_fit_powerspectrum_result gti: %s" % gti_filename) logging.debug("get_fit_powerspectrum_result: filters %s" % filters) logging.debug("get_fit_powerspectrum_result: axis %s" % axis) - logging.debug("get_fit_powerspectrum_result: dt %f" % dt) + logging.debug("get_fit_powerspectrum_result: dt %s" % dt) logging.debug("get_fit_powerspectrum_result: nsegm %f" % nsegm) logging.debug("get_fit_powerspectrum_result: segm_size %f" % segm_size) logging.debug("get_fit_powerspectrum_result: norm %s" % norm) @@ -644,7 +644,7 @@ def get_bootstrap_results(src_filename, bck_filename, gti_filename, target, logging.debug("get_bootstrap_results gti: %s" % gti_filename) logging.debug("get_bootstrap_results: filters %s" % filters) logging.debug("get_bootstrap_results: axis %s" % axis) - logging.debug("get_bootstrap_results: dt %f" % dt) + logging.debug("get_bootstrap_results: dt %s" % dt) logging.debug("get_bootstrap_results: nsegm %f" % nsegm) logging.debug("get_bootstrap_results: segm_size %f" % segm_size) logging.debug("get_bootstrap_results: norm %s" % norm) @@ -717,7 +717,7 @@ def get_lomb_scargle(src_filename, bck_filename, gti_filename, target, logging.debug("get_lomb_scargle gti: %s" % gti_filename) logging.debug("get_lomb_scargle: filters %s" % filters) logging.debug("get_lomb_scargle: axis %s" % axis) - logging.debug("get_lomb_scargle: dt %f" % dt) + logging.debug("get_lomb_scargle: dt %s" % dt) logging.debug("get_lomb_scargle: freq_range %s" % freq_range) logging.debug("get_lomb_scargle: nyquist_factor %s" % nyquist_factor) logging.debug("get_lomb_scargle: ls_norm %s" % ls_norm) @@ -757,7 +757,7 @@ def get_pulse_search(src_filename, bck_filename, gti_filename, target, logging.debug("get_pulse_search gti: %s" % gti_filename) logging.debug("get_pulse_search: filters %s" % filters) logging.debug("get_pulse_search: axis %s" % axis) - logging.debug("get_pulse_search: dt %f" % dt) + logging.debug("get_pulse_search: dt %s" % dt) logging.debug("get_pulse_search: freq_range %s" % freq_range) logging.debug("get_pulse_search: mode %s" % mode) logging.debug("get_pulse_search: oversampling %s" % oversampling) @@ -798,7 +798,7 @@ def get_phaseogram(src_filename, bck_filename, gti_filename, target, logging.debug("get_phaseogram gti: %s" % gti_filename) logging.debug("get_phaseogram: filters %s" % filters) logging.debug("get_phaseogram: axis %s" % axis) - logging.debug("get_phaseogram: dt %f" % dt) + logging.debug("get_phaseogram: dt %s" % dt) logging.debug("get_phaseogram: f %s" % f) logging.debug("get_phaseogram: nph %s" % nph) logging.debug("get_phaseogram: nt %s" % nt) diff --git a/src/main/python/utils/dave_engine.py b/src/main/python/utils/dave_engine.py index 43fe042..76a9672 100644 --- a/src/main/python/utils/dave_engine.py +++ b/src/main/python/utils/dave_engine.py @@ -169,7 +169,7 @@ def apply_rmf_file_to_dataset(destination, rmf_destination): # @param: filters: array with the filters to apply # [{ table = "txt_table", column = "Time", from=0, to=10 }, ... ] # @param: styles: dictionary with the plot style info -# { type = "2d", labels=["Time", "Rate Count"]} +# { type = "2d", ... } # @param: axis: array with the column names to use in ploting # [{ table = "txt_table", column = "Time" }, # { table = "txt_table", column = "Rate" } ... ] @@ -186,14 +186,6 @@ def get_plot_data(src_destination, bck_destination, gti_destination, filters, st logging.warn("No plot type specified on styles") return None - if "labels" not in styles: - logging.warn("No plot labels specified on styles") - return None - - if len(styles["labels"]) < 2: - logging.warn("Wrong number of labels specified on styles") - return None - if len(axis) < 2: logging.warn("Wrong number of axis") return None @@ -203,15 +195,6 @@ def get_plot_data(src_destination, bck_destination, gti_destination, filters, st return Plotter.get_plotdiv_xy(filtered_ds, axis) elif styles["type"] == "3d": - - if len(styles["labels"]) < 3: - logging.warn("Wrong number of labels specified on styles") - return None - - if len(axis) < 3: - logging.warn("Wrong number of axis") - return None - return Plotter.get_plotdiv_xyz(filtered_ds, axis) elif styles["type"] == "scatter": @@ -664,6 +647,9 @@ def get_dynamical_spectrum(src_destination, bck_destination, gti_destination, pds = AveragedPowerspectrum(lc=lc, segment_size=segm_size, norm=norm, gti=gti) if pds: + + pds = rebin_spectrum_if_necessary(pds) + freq = pds.freq pds_array, nphots_all = pds._make_segment_spectrum(lc, segm_size) @@ -1166,6 +1152,8 @@ def get_rms_spectrum(src_destination, bck_destination, gti_destination, if pds: + pds = rebin_spectrum_if_necessary(pds) + if freq_range[0] < 0: freq_low = min(pds.freq) else: @@ -1486,12 +1474,17 @@ def get_bootstrap_results(src_destination, bck_destination, gti_destination, else: sim_pds = AveragedPowerspectrum(lc=sim_lc, segment_size=segm_size, norm=norm, gti=gti) - parest, res = fit_powerspectrum(sim_pds, fit_model, starting_pars, - max_post=False, priors=None, fitmethod="L-BFGS-B") + if sim_pds: + sim_pds = rebin_spectrum_if_necessary(sim_pds) + + parest, res = fit_powerspectrum(sim_pds, fit_model, starting_pars, + max_post=False, priors=None, fitmethod="L-BFGS-B") - models_params.append(res.p_opt) - powers.append(sim_pds.power) + models_params.append(res.p_opt) + powers.append(sim_pds.power) + else: + logging.warn(ExHelper.getException('get_bootstrap_results: cant create powerspectrum for i: ' + str(i))) except: logging.error(ExHelper.getException('get_bootstrap_results for i: ' + str(i))) @@ -2008,9 +2001,25 @@ def create_power_density_spectrum(src_destination, bck_destination, gti_destinat logging.debug("Create power density spectrum") if pds_type == 'Sng': - return Powerspectrum(lc, norm=norm, gti=gti), lc, gti + pds = Powerspectrum(lc, norm=norm, gti=gti) + else: + pds = AveragedPowerspectrum(lc=lc, segment_size=segm_size, norm=norm, gti=gti) + + if pds: + pds = rebin_spectrum_if_necessary(pds) else: - return AveragedPowerspectrum(lc=lc, segment_size=segm_size, norm=norm, gti=gti), lc, gti + logging.warn("Can't create power spectrum") + + return pds, lc, gti + + +def rebin_spectrum_if_necessary (pds): + freq_size = len(pds.freq) + if freq_size > CONFIG.MAX_PLOT_POINTS: + df = (max(pds.freq) - min(pds.freq)) / CONFIG.MAX_PLOT_POINTS + logging.warn("Spectrum rebined to " + str(CONFIG.MAX_PLOT_POINTS) + " points, from " + str(freq_size) + " points, with df: " + str(df)) + pds = pds.rebin(df=df) + return pds def get_countrate_from_lc_ds (lc_destination, bck_destination, lc_name, bck_name): diff --git a/src/main/python/utils/dave_reader.py b/src/main/python/utils/dave_reader.py index 6994549..6c31e05 100644 --- a/src/main/python/utils/dave_reader.py +++ b/src/main/python/utils/dave_reader.py @@ -197,6 +197,10 @@ def get_events_fits_dataset_with_stingray(destination, hdulist, dsId='FITS', event_list, events_start_time = substract_tstart_from_events(fits_data, time_offset) + # Gets PI column data from eventlist if requiered and not in additional_data + if "PI" in additional_columns and "PI" not in fits_data.additional_data: + fits_data.additional_data["PI"] = event_list.pi + dataset = DataSet.get_dataset_applying_gtis(dsId, header, header_comments, fits_data.additional_data, [], event_list.time, [], diff --git a/src/main/resources/static/scripts/common.js b/src/main/resources/static/scripts/common.js index b0fbfe3..5847af6 100644 --- a/src/main/resources/static/scripts/common.js +++ b/src/main/resources/static/scripts/common.js @@ -20,13 +20,23 @@ function fillWithZeros(num, length) { } function closest(arr, closestTo){ - var closest = Math.max.apply(null, arr); + var closest = minMax2DArray(arr).max; for(var i = 0; i < arr.length; i++){ if(arr[i] >= closestTo && arr[i] < closest) closest = arr[i]; } return closest; } +function minMax2DArray(arr) { + var max = Number.MIN_VALUE, + min = Number.MAX_VALUE; + arr.forEach(function(e) { + if (max < e) { max = e; } + if (min > e) { min = e; } + }); + return {max: max, min: min}; +} + function getStepSizeFromRange(range, numSteps) { var multiplier = 1; //If range is smaller than 1.0 find the divisor @@ -36,6 +46,15 @@ function getStepSizeFromRange(range, numSteps) { return (1.0 / multiplier) / numSteps; } +function getPrecisionFromFloat(value) { + var strVal = value + ""; + if (strVal.indexOf(".") > -1){ + return strVal.split(".")[1].length; + } else { + return Math.pow(10, -strVal.length); + } +} + // ------- CLIPBOARD AND FILE MEHTODS ------- function copyToClipboard(text) { diff --git a/src/main/resources/static/scripts/config.js b/src/main/resources/static/scripts/config.js index 9cf3a88..6aea3fd 100644 --- a/src/main/resources/static/scripts/config.js +++ b/src/main/resources/static/scripts/config.js @@ -17,5 +17,7 @@ CONFIG = { BULK_ANALYSIS_ENABLED: false, LOG_TO_SERVER_ENABLED: true, //If true, python server logs will be visible from GUI Log tab LOG_LEVEL: -1, // PYTHON SERVER LOG LEVEL -> ALL = -1, DEBUG = 0, INFO = 1, WARN = 2, ERROR = 3, NONE = 4 - DENY_BCK_IF_SUBS: true //Avoid set background file if lightcurve bck data is allready substracted + DENY_BCK_IF_SUBS: true, //Avoid set background file if lightcurve bck data is allready substracted + MAX_TIME_RESOLUTION_DECIMALS: 5, //Defines the maximun time resolution of DAVE GUI, default 100ns + DEFAULT_NUMBER_DECIMALS: 3 //The defaul number precision on selectors and textboxes } diff --git a/src/main/resources/static/scripts/master_page.js b/src/main/resources/static/scripts/master_page.js index 09c9cf8..9c0b87a 100644 --- a/src/main/resources/static/scripts/master_page.js +++ b/src/main/resources/static/scripts/master_page.js @@ -9,9 +9,7 @@ $(document).ready(function () { theService = new Service(CONFIG.DOMAIN_URL); theService.subscribe_to_server_messages(onServerMessageReceived); - theService.set_config({ CONFIG: CONFIG }, function (res) { - logInfo("Server configuration setted -> " + res); - }) + updateServerConfig(); $("#navbar").find(".addTabPanel").click(function () { addWfTabPanel($("#navbar").find("ul").first(), $(".daveContainer")); @@ -243,3 +241,9 @@ function onServerMessageReceived (msg) { } log("SERVER -> " + msg, cssClass); } + +function updateServerConfig(){ + theService.set_config({ CONFIG: CONFIG }, function (res) { + logInfo("Server configuration setted -> " + res); + }) +} diff --git a/src/main/resources/static/scripts/outputPanels/wfOutputPanel.js b/src/main/resources/static/scripts/outputPanels/wfOutputPanel.js index 7132455..dc733d2 100644 --- a/src/main/resources/static/scripts/outputPanels/wfOutputPanel.js +++ b/src/main/resources/static/scripts/outputPanels/wfOutputPanel.js @@ -697,6 +697,28 @@ function WfOutputPanel (id, classSelector, container, service, onFiltersChangedF ); } + /*this.getEventsPlot = function ( projectConfig ){ + var eventPlotId = this.generatePlotId("events_" + projectConfig.filename); + return new Plot( + eventPlotId, + { + id: eventPlotId, + selectorKey: "SRC", + filename: projectConfig.filename, + bck_filename: "", + gti_filename: "", + styles: { type: "2d", labels: ["TIME", "PI"], title: "EVENTS" }, + axis: [ { table: "EVENTS", column:"TIME" }, + { table: "EVENTS", column:"PI" } ] + }, + this.service.request_plot_data, + this.onFiltersChangedFromPlot, + this.onPlotReady, + getTabForSelector(this.id).$html.find(".LcPlot").find(".sectionContainer"), + "LcPlot fullWidth", + false + ); + }*/ log ("Workflow Output panel ready!!"); return this; diff --git a/src/main/resources/static/scripts/plots/covariancePlot.js b/src/main/resources/static/scripts/plots/covariancePlot.js index 4e69b30..7355bcc 100644 --- a/src/main/resources/static/scripts/plots/covariancePlot.js +++ b/src/main/resources/static/scripts/plots/covariancePlot.js @@ -51,17 +51,11 @@ function CovariancePlot(id, plotConfig, getDataFromServerFn, onFiltersChangedFn, "From", "To", this.plotConfig.ref_band_interest[0], this.plotConfig.ref_band_interest[1], this.onReferenceBandValuesChanged, - null); - this.refBandSelector.slider.slider({ - min: this.refBandSelector.fromValue, - max: this.refBandSelector.toValue, - values: [this.refBandSelector.fromValue, this.refBandSelector.toValue], - step: CONFIG.ENERGY_FILTER_STEP, - slide: function( event, ui ) { - currentObj.refBandSelector.setValues( ui.values[ 0 ], ui.values[ 1 ], "slider"); - currentObj.onReferenceBandValuesChanged(); - } - }); + null, + function( event, ui ) { + currentObj.refBandSelector.setValues( ui.values[ 0 ], ui.values[ 1 ], "slider"); + currentObj.onReferenceBandValuesChanged(); + }); this.refBandSelector.setFixedStep(CONFIG.ENERGY_FILTER_STEP); this.refBandSelector.setEnabled(true); this.settingsPanel.find(".leftCol").append(this.refBandSelector.$html); diff --git a/src/main/resources/static/scripts/plots/dynSpPlot.js b/src/main/resources/static/scripts/plots/dynSpPlot.js index 1e71581..46302e6 100644 --- a/src/main/resources/static/scripts/plots/dynSpPlot.js +++ b/src/main/resources/static/scripts/plots/dynSpPlot.js @@ -39,10 +39,19 @@ function DynSpPlot(id, plotConfig, getDataFromServerFn, onFiltersChangedFn, onPl currentObj.refreshData(); }); - this.updateMaxMinFreq = function () { - this.plotConfig.maxSupportedFreq = 0.6 / this.plotConfig.dt; - this.plotConfig.freqMax = Math.min(this.plotConfig.maxSupportedFreq, this.plotConfig.freqMax); - this.plotConfig.freqMin = Math.max(0.0, this.plotConfig.freqMin); + this.updateMaxMinFreq = function (forceMaxFreq) { + this.plotConfig.maxSupportedFreq = 0.6 / this.getBinSize(); + this.plotConfig.freqMax = (!isNull(forceMaxFreq) && forceMaxFreq) ? this.plotConfig.maxSupportedFreq : Math.min(this.plotConfig.maxSupportedFreq, this.plotConfig.freqMax); + this.plotConfig.freqMin = (!isNull(forceMaxFreq) && forceMaxFreq) ? 0.0 : Math.max(0.0, this.plotConfig.freqMin); + } + + this.onBinSizeChanged = function () { + currentObj.plotConfig.dt = currentObj.binSelector.value; + currentObj.updateSegmSelector(); + currentObj.updateMaxMinFreq(true); + if (!isNull(currentObj.freqSelector)) { + currentObj.freqSelector.setMinMaxValues (currentObj.plotConfig.freqMin, currentObj.plotConfig.freqMax); + } } this.prepareData = function (data) { @@ -110,6 +119,8 @@ function DynSpPlot(id, plotConfig, getDataFromServerFn, onFiltersChangedFn, onPl this.plotConfig.duration = data[3].values[0]; } + this.updateSettings(); + } else { this.showWarn("Wrong data received"); } @@ -234,19 +245,14 @@ function DynSpPlot(id, plotConfig, getDataFromServerFn, onFiltersChangedFn, onPl "From", "To", this.plotConfig.freqMin, this.plotConfig.freqMax, this.onFreqSelectorValuesChanged, - null); - this.freqSelector.step = 0.01; + null, + function( event, ui ) { + currentObj.freqSelector.setValues( ui.values[ 0 ], ui.values[ 1 ], "slider" ); + currentObj.onFreqSelectorValuesChanged(); + }, + null, + getStepSizeFromRange(this.plotConfig.freqMax - this.plotConfig.freqMin, 100)); this.freqSelector.setDisableable(false); - this.freqSelector.slider.slider({ - min: this.freqSelector.fromValue, - max: this.freqSelector.toValue, - values: [ this.freqSelector.fromValue, this.freqSelector.toValue ], - step: this.freqSelector.step, - slide: function( event, ui ) { - currentObj.freqSelector.setValues( ui.values[ 0 ], ui.values[ 1 ], "slider" ); - currentObj.onFreqSelectorValuesChanged(); - } - }); this.freqSelector.inputChanged = function ( event ) { currentObj.setValues( getInputFloatValue(currentObj.freqSelector.fromInput, currentObj.freqSelector.fromValue), getInputFloatValue(currentObj.freqSelector.toInput, currentObj.freqSelector.toValue) ); @@ -266,17 +272,11 @@ function DynSpPlot(id, plotConfig, getDataFromServerFn, onFiltersChangedFn, onPl "x0:", "From", 0.0, 1.0, 0.01, 0.5, - this.onX0SelectorValuesChanged); - this.x0Selector.slider.slider({ - min: this.x0Selector.fromValue, - max: this.x0Selector.toValue, - values: [this.x0Selector.value], - step: this.x0Selector.step, - slide: function( event, ui ) { - currentObj.x0Selector.setValues( ui.values[ 0 ], "slider"); - currentObj.onX0SelectorValuesChanged(); - } - }); + this.onX0SelectorValuesChanged, + function( event, ui ) { + currentObj.x0Selector.setValues( ui.values[ 0 ], "slider"); + currentObj.onX0SelectorValuesChanged(); + }); this.x0Selector.inputChanged = function ( event ) { currentObj.x0Selector.setValues( getInputFloatValue(currentObj.x0Selector.fromInput, currentObj.x0Selector.value) ); currentObj.onX0SelectorValuesChanged(); @@ -288,17 +288,11 @@ function DynSpPlot(id, plotConfig, getDataFromServerFn, onFiltersChangedFn, onPl "y0:", "From", 0.0, 1.0, 0.01, 0.5, - this.onY0SelectorValuesChanged); - this.y0Selector.slider.slider({ - min: this.y0Selector.fromValue, - max: this.y0Selector.toValue, - values: [this.y0Selector.value], - step: this.y0Selector.step, - slide: function( event, ui ) { - currentObj.y0Selector.setValues( ui.values[ 0 ], "slider"); - currentObj.onY0SelectorValuesChanged(); - } - }); + this.onY0SelectorValuesChanged, + function( event, ui ) { + currentObj.y0Selector.setValues( ui.values[ 0 ], "slider"); + currentObj.onY0SelectorValuesChanged(); + }); this.y0Selector.inputChanged = function ( event ) { currentObj.y0Selector.setValues( getInputFloatValue(currentObj.y0Selector.fromInput, currentObj.y0Selector.value) ); currentObj.onY0SelectorValuesChanged(); @@ -310,17 +304,11 @@ function DynSpPlot(id, plotConfig, getDataFromServerFn, onFiltersChangedFn, onPl "m:", "From", 0.0, 1.0, 0.01, 0.25, - this.onMSelectorValuesChanged); - this.mSelector.slider.slider({ - min: this.mSelector.fromValue, - max: this.mSelector.toValue, - values: [this.mSelector.value], - step: this.mSelector.step, - slide: function( event, ui ) { - currentObj.mSelector.setValues( ui.values[ 0 ], "slider"); - currentObj.onMSelectorValuesChanged(); - } - }); + this.onMSelectorValuesChanged, + function( event, ui ) { + currentObj.mSelector.setValues( ui.values[ 0 ], "slider"); + currentObj.onMSelectorValuesChanged(); + }); this.mSelector.inputChanged = function ( event ) { currentObj.mSelector.setValues( getInputFloatValue(currentObj.mSelector.fromInput, currentObj.mSelector.value) ); currentObj.onMSelectorValuesChanged(); diff --git a/src/main/resources/static/scripts/plots/fitPlot.js b/src/main/resources/static/scripts/plots/fitPlot.js index 8a69747..c0aa0cd 100644 --- a/src/main/resources/static/scripts/plots/fitPlot.js +++ b/src/main/resources/static/scripts/plots/fitPlot.js @@ -24,6 +24,11 @@ function FitPlot(id, plotConfig, getModelsFn, getDataFromServerFn, getModelsData if (!isNull(data.abort)){ log("Current request aborted, Plot: " + currentObj.id); + if (data.statusText == "error"){ + //If abort cause is because python server died + currentObj.setReadyState(true); + currentObj.showWarn("Connection lost!"); + } return; //Comes from request abort call. } diff --git a/src/main/resources/static/scripts/plots/lcPlot.js b/src/main/resources/static/scripts/plots/lcPlot.js index 6229c55..ef92c8c 100644 --- a/src/main/resources/static/scripts/plots/lcPlot.js +++ b/src/main/resources/static/scripts/plots/lcPlot.js @@ -108,10 +108,12 @@ function LcPlot(id, plotConfig, getDataFromServerFn, onFiltersChangedFn, onPlotR this.updateMinMaxCoords = function (){ if (this.data != null) { var coords = this.getSwitchedCoords( { x: 0, y: 1} ); - this.minX = Math.min.apply(null, this.data[coords.x].values); - this.minY = Math.min.apply(null, this.data[coords.y].values); - this.maxX = Math.max.apply(null, this.data[coords.x].values); - this.maxY = Math.max.apply(null, this.data[coords.y].values); + var minMaxX = minMax2DArray(this.data[coords.x].values); + var minMaxY = minMax2DArray(this.data[coords.y].values); + this.minX = minMaxX.min; + this.minY = minMaxY.min; + this.maxX = minMaxX.max; + this.maxY = minMaxY.max; var tab = getTabForSelector(this.id); if (!isNull(tab) && (0 <= this.minY < this.maxY)){ diff --git a/src/main/resources/static/scripts/plots/pdsPlot.js b/src/main/resources/static/scripts/plots/pdsPlot.js index 2f0f470..5095f9c 100644 --- a/src/main/resources/static/scripts/plots/pdsPlot.js +++ b/src/main/resources/static/scripts/plots/pdsPlot.js @@ -42,7 +42,7 @@ function PDSPlot(id, plotConfig, getDataFromServerFn, onFiltersChangedFn, onPlot //PDS plot methods: this.addSettingsControls = function(){ - if (this.settingsPanel.find(".sliderSelector").length == 0) { + if (this.settingsPanel.find(".pdsNorm").length == 0) { if (isNull(this.plotConfig.styles.showPdsType) || this.plotConfig.styles.showPdsType){ // Creates PDS type radio buttons @@ -68,7 +68,7 @@ function PDSPlot(id, plotConfig, getDataFromServerFn, onFiltersChangedFn, onPlot // Creates the Segment length selector var tab = getTabForSelector(this.id); - var binSize = this.plotConfig.dt; + var binSize = this.getBinSize(); var segmSize = this.plotConfig.segment_size; var minValue = binSize * CONFIG.MIN_SEGMENT_MULTIPLIER; var maxValue = (this.plotConfig.maxSegmentSize > 0) ? this.plotConfig.maxSegmentSize : segmSize * 100; @@ -80,18 +80,12 @@ function PDSPlot(id, plotConfig, getDataFromServerFn, onFiltersChangedFn, onPlot "Segment Length (" + tab.projectConfig.timeUnit + "):", "From", minValue, maxValue, binSize, segmSize, - this.onSegmSelectorValuesChanged); + this.onSegmSelectorValuesChanged, + function( event, ui ) { + currentObj.segmSelector.setValues( ui.values[ 0 ], "slider"); + currentObj.onSegmSelectorValuesChanged(); + }); this.segmSelector.setTitle("Segment Length (" + tab.projectConfig.timeUnit + "): Nº Segments= " + fixedPrecision(this.plotConfig.nsegm, 2) + ""); - this.segmSelector.slider.slider({ - min: this.segmSelector.fromValue, - max: this.segmSelector.toValue, - values: [this.segmSelector.value], - step: this.segmSelector.step, - slide: function( event, ui ) { - currentObj.segmSelector.setValues( ui.values[ 0 ], "slider"); - currentObj.onSegmSelectorValuesChanged(); - } - }); this.segmSelector.inputChanged = function ( event ) { currentObj.segmSelector.setValues( getInputFloatValue(currentObj.segmSelector.fromInput, currentObj.plotConfig.segment_size) ); currentObj.onSegmSelectorValuesChanged(); @@ -126,32 +120,26 @@ function PDSPlot(id, plotConfig, getDataFromServerFn, onFiltersChangedFn, onPlot // Creates the Plot Binnin Size selector - this.binSelector = new BinSelector(this.id + "_binSelector", + this.rebinSelector = new BinSelector(this.id + "_rebinSelector", "Binning (Freq):", "From", this.plotConfig.minRebinSize, this.plotConfig.maxRebinSize, this.plotConfig.minRebinSize, this.plotConfig.rebinSize, - this.onBinSelectorValuesChanged); - this.binSelector.setDisableable(true); - this.binSelector.setEnabled(currentObj.plotConfig.rebinEnabled); - this.binSelector.switchBox.click( function ( event ) { + this.onBinSelectorValuesChanged, + function( event, ui ) { + currentObj.rebinSelector.setValues( ui.values[ 0 ], "slider"); + currentObj.onBinSelectorValuesChanged(); + }); + this.rebinSelector.setDisableable(true); + this.rebinSelector.setEnabled(currentObj.plotConfig.rebinEnabled); + this.rebinSelector.switchBox.click( function ( event ) { currentObj.plotConfig.rebinEnabled = !currentObj.plotConfig.rebinEnabled; - currentObj.binSelector.setEnabled(currentObj.plotConfig.rebinEnabled); + currentObj.rebinSelector.setEnabled(currentObj.plotConfig.rebinEnabled); }); - this.binSelector.slider.slider({ - min: this.binSelector.fromValue, - max: this.binSelector.toValue, - values: [this.binSelector.value], - step: this.binSelector.step, - slide: function( event, ui ) { - currentObj.binSelector.setValues( ui.values[ 0 ], "slider"); - currentObj.onBinSelectorValuesChanged(); - } - }); - this.binSelector.inputChanged = function ( event ) { - currentObj.binSelector.setValues( getInputFloatValue(currentObj.binSelector.fromInput, currentObj.binSelector.value) ); + this.rebinSelector.inputChanged = function ( event ) { + currentObj.rebinSelector.setValues( getInputFloatValue(currentObj.rebinSelector.fromInput, currentObj.rebinSelector.value) ); currentObj.onBinSelectorValuesChanged(); }; - this.settingsPanel.find(".leftCol").append(this.binSelector.$html); + this.settingsPanel.find(".leftCol").append(this.rebinSelector.$html); this.addAxesTypeControlsToSettings(".rightCol"); @@ -179,7 +167,7 @@ function PDSPlot(id, plotConfig, getDataFromServerFn, onFiltersChangedFn, onPlot } this.updateSettings = function(){ - if (this.settingsPanel.find(".sliderSelector").length > 0) { + if (this.settingsPanel.find(".pdsNorm").length > 0) { if (!isNull(this.segmSelector)){ if ((this.segmSelector.step != this.plotConfig.binSize) @@ -211,6 +199,7 @@ function PDSPlot(id, plotConfig, getDataFromServerFn, onFiltersChangedFn, onPlot this.updateSegmSelector = function () { var tab = getTabForSelector(currentObj.id); currentObj.segmSelector.setTitle("Segment Length (" + tab.projectConfig.timeUnit + "): Nº Segments= " + fixedPrecision(currentObj.plotConfig.nsegm, 2) + ""); + currentObj.segmSelector.setStep(this.getBinSize()); if (Math.floor(currentObj.plotConfig.nsegm) <= 1){ //If NSegm = 1, set normalization to leahy @@ -219,16 +208,27 @@ function PDSPlot(id, plotConfig, getDataFromServerFn, onFiltersChangedFn, onPlot } } + this.onBinSizeChanged = function () { + currentObj.plotConfig.dt = currentObj.binSelector.value; + currentObj.updateSegmSelector(); + } + this.onBinSelectorValuesChanged = function(){ if (currentObj.plotConfig.duration > 0) { - currentObj.plotConfig.rebinSize = currentObj.binSelector.value; + currentObj.plotConfig.rebinSize = currentObj.rebinSelector.value; } } this.updatePlotConfig = function () { + var binSize = this.getBinSize(); + if (!isNull(binSize)){ + this.plotConfig.dt = binSize; + } else { + log("ERROR on updatePlotConfig: BinSize is null, Plot: " + this.id); + } + var tab = getTabForSelector(this.id); if (!isNull(tab)) { - this.plotConfig.dt = tab.projectConfig.binSize; this.plotConfig.maxSegmentSize = !isNull(this.plotConfig.zAxisType) ? tab.projectConfig.maxSegmentSize / 2 : tab.projectConfig.maxSegmentSize; this.plotConfig.segment_size = !isNull(this.segmSelector) ? Math.min(this.segmSelector.value, this.plotConfig.maxSegmentSize) : this.plotConfig.maxSegmentSize / CONFIG.DEFAULT_SEGMENT_DIVIDER; this.updateNSegm(); diff --git a/src/main/resources/static/scripts/plots/pgPlot.js b/src/main/resources/static/scripts/plots/pgPlot.js index c8f0d69..4d2cfda 100644 --- a/src/main/resources/static/scripts/plots/pgPlot.js +++ b/src/main/resources/static/scripts/plots/pgPlot.js @@ -22,8 +22,8 @@ function PgPlot(id, plotConfig, getDataFromServerFn, onFiltersChangedFn, onPlotR this.getDefaultFreqRange = function (){ if (this.plotConfig.default_freq_range[0] < 0 && !isNull(this.data) && this.data.length >= 4) { - this.plotConfig.default_freq_range = [ Math.min.apply(null, this.data[0].values), - Math.max.apply(null, this.data[0].values) ]; + var minMax = minMax2DArray(this.data[0].values); + this.plotConfig.default_freq_range = [ minMax.min, minMax.max ]; } return this.plotConfig.default_freq_range; } diff --git a/src/main/resources/static/scripts/plots/plot.js b/src/main/resources/static/scripts/plots/plot.js index b0905d6..a4ddd03 100644 --- a/src/main/resources/static/scripts/plots/plot.js +++ b/src/main/resources/static/scripts/plots/plot.js @@ -220,11 +220,21 @@ function Plot(id, plotConfig, getDataFromServerFn, onFiltersChangedFn, onPlotRea } this.updatePlotConfig = function () { + var binSize = this.getBinSize(); + if (!isNull(binSize)){ + this.plotConfig.dt = binSize; + } else { + log("ERROR on updatePlotConfig: BinSize is null, Plot: " + this.id); + } + } + + this.getBinSize = function () { var tab = getTabForSelector(this.id); if (!isNull(tab)){ - this.plotConfig.dt = tab.projectConfig.binSize; + return tab.projectConfig.binSize; } else { - log("ERROR on updatePlotConfig: Plot not attached to tab, Plot: " + this.id); + log("ERROR on getBinSize: Plot not attached to tab, Plot: " + this.id); + return null; } } @@ -232,6 +242,11 @@ function Plot(id, plotConfig, getDataFromServerFn, onFiltersChangedFn, onPlotRea if (!isNull(data.abort)){ log("Current request aborted, Plot: " + currentObj.id); + if (data.statusText == "error"){ + //If abort cause is because python server died + currentObj.setReadyState(true); + currentObj.showWarn("Connection lost!"); + } return; //Comes from request abort call. } @@ -608,10 +623,12 @@ function Plot(id, plotConfig, getDataFromServerFn, onFiltersChangedFn, onPlotRea this.updateMinMaxCoords = function (){ if (this.data != null) { var coords = this.getSwitchedCoords( { x: 0, y: 1} ); - this.minX = Math.min.apply(null, this.data[coords.x].values); - this.minY = Math.min.apply(null, this.data[coords.y].values); - this.maxX = Math.max.apply(null, this.data[coords.x].values); - this.maxY = Math.max.apply(null, this.data[coords.y].values); + var minMaxX = minMax2DArray(this.data[coords.x].values); + var minMaxY = minMax2DArray(this.data[coords.y].values); + this.minX = minMaxX.min; + this.minY = minMaxY.min; + this.maxX = minMaxX.max; + this.maxY = minMaxY.max; } } diff --git a/src/main/resources/static/scripts/plots/plotWithSettings.js b/src/main/resources/static/scripts/plots/plotWithSettings.js index 74fe2cc..2222ac4 100644 --- a/src/main/resources/static/scripts/plots/plotWithSettings.js +++ b/src/main/resources/static/scripts/plots/plotWithSettings.js @@ -44,6 +44,7 @@ function PlotWithSettings(id, plotConfig, getDataFromServerFn, onFiltersChangedF if (!this.settingsVisible) { this.settingsVisible = true; this.setHoverDisablerEnabled(false); + this.setLegendText(""); var height = parseInt(this.$html.find(".plot").height()); this.$html.find(".plot").hide(); this.$html.find(".plotTools").children().hide(); @@ -54,6 +55,8 @@ function PlotWithSettings(id, plotConfig, getDataFromServerFn, onFiltersChangedF } this.setSettingsTitle(title); + this.addBinSizeSelectorToSettings(".leftCol"); + this.addSettingsControls(); if (!this.$html.hasClass("fullWidth") && this.settingsPanel.find(".rightCol").children().length == 0){ @@ -166,7 +169,7 @@ function PlotWithSettings(id, plotConfig, getDataFromServerFn, onFiltersChangedF } } else { - log ("PlotWithSettings id: " + this.id + " - addAxesTypeControlsToSettings ERROR: plotConfig.xAxisType or plotConfig.yAxisType not initialized!"); + logErr ("PlotWithSettings id: " + this.id + " - addAxesTypeControlsToSettings ERROR: plotConfig.xAxisType or plotConfig.yAxisType not initialized!"); } } @@ -186,17 +189,11 @@ function PlotWithSettings(id, plotConfig, getDataFromServerFn, onFiltersChangedF "From", "To", this.plotConfig.default_energy_range[0], this.plotConfig.default_energy_range[1], this.onEnergyRangeValuesChanged, - null); - this.energyRangeSelector.slider.slider({ - min: this.energyRangeSelector.fromValue, - max: this.energyRangeSelector.toValue, - values: [this.energyRangeSelector.fromValue, this.energyRangeSelector.toValue], - step: CONFIG.ENERGY_FILTER_STEP, - slide: function( event, ui ) { - currentObj.energyRangeSelector.setValues( ui.values[ 0 ], ui.values[ 1 ], "slider"); - currentObj.onEnergyRangeValuesChanged(); - } - }); + null, + function( event, ui ) { + currentObj.energyRangeSelector.setValues( ui.values[ 0 ], ui.values[ 1 ], "slider"); + currentObj.onEnergyRangeValuesChanged(); + }); this.energyRangeSelector.setFixedStep(CONFIG.ENERGY_FILTER_STEP); this.energyRangeSelector.setEnabled(true); @@ -204,7 +201,7 @@ function PlotWithSettings(id, plotConfig, getDataFromServerFn, onFiltersChangedF this.settingsPanel.find(columnClass).append(this.energyRangeSelector.$html); } else { - log ("PlotWithSettings id: " + this.id + " - addEnergyRangeControlToSetting ERROR: plotConfig.energy_range not initialized!"); + logErr ("PlotWithSettings id: " + this.id + " - addEnergyRangeControlToSetting ERROR: plotConfig.energy_range not initialized!"); } } @@ -218,7 +215,95 @@ function PlotWithSettings(id, plotConfig, getDataFromServerFn, onFiltersChangedF }); } else { - log ("PlotWithSettings id: " + this.id + " - addNumberOfBandsControlToSettings ERROR: plotConfig.n_bands not initialized!"); + logErr ("PlotWithSettings id: " + this.id + " - addNumberOfBandsControlToSettings ERROR: plotConfig.n_bands not initialized!"); + } + } + + this.addBinSizeSelectorToSettings = function (columnClass) { + if (this.settingsPanel.find(".binSelectorCheckBox").length > 0) { + return; + } + + if (!isNull(this.plotConfig.dt)) { + + //Adds bin size selector to plot + var tab = getTabForSelector(currentObj.id); + if (!isNull(tab) && !isNull(tab.toolPanel.binSelector)){ + + var enabled = !isNull(this.binSelector) && this.binSelector.enabled; + var binSize = (enabled) ? this.plotConfig.dt : tab.projectConfig.binSize; + + //Adds the custom binSize switch + var $binSelectorCheckBox = $('
' + + 'Use general bin size' + + '
' + + '' + + '
' + + '
'); + $binSelectorCheckBox.find(".switch-btn").click( function ( event ) { + var checkBox = $(this); + if (checkBox.hasClass("fa-square-o")){ + checkBox.switchClass("fa-square-o", "fa-check-square-o"); + checkBox.parent().parent().addClass("Orange"); + currentObj.binSelector.enabled = false; + currentObj.binSelector.$html.fadeOut(); + } else { + checkBox.switchClass("fa-check-square-o", "fa-square-o"); + checkBox.parent().parent().removeClass("Orange"); + currentObj.binSelector.enabled = true; + currentObj.binSelector.setValues(tab.projectConfig.binSize); + currentObj.binSelector.$html.fadeIn(); + } + currentObj.onBinSizeChanged(); + }); + this.settingsPanel.find(columnClass).append($binSelectorCheckBox); + + //Caluculates intial, max, min and step values for slider with time ranges + var binSelectorConfig = getBinSelectorConfig(tab.projectConfig); + + this.binSelector = new BinSelector(this.id + "_binSelector", + "BIN SIZE (" + tab.projectConfig.timeUnit + "):", + "From", + tab.projectConfig.minBinSize, + tab.projectConfig.maxBinSize, + binSelectorConfig.step, + binSize, + this.onBinSizeChanged, + function( event, ui ) { + currentObj.binSelector.setValues( ui.values[ 0 ], "slider"); + currentObj.onBinSizeChanged(); + }, + CONFIG.MAX_TIME_RESOLUTION_DECIMALS); + this.binSelector.inputChanged = function ( event ) { + currentObj.binSelector.setValues( getInputFloatValue(currentObj.binSelector.fromInput, currentObj.plotConfig.dt) ); + currentObj.onBinSizeChanged(); + }; + + this.binSelector.enabled = enabled; + setVisibility(this.binSelector.$html, enabled); + + this.settingsPanel.find(columnClass).append(this.binSelector.$html); + } + } else { + logErr ("PlotWithSettings id: " + this.id + " - addBinSizeSelectorToSettings ERROR: plotConfig.dt is null!"); + } + } + + this.onBinSizeChanged = function () { + currentObj.plotConfig.dt = currentObj.binSelector.value; + } + + this.getBinSize = function () { + if (isNull(currentObj.binSelector) || !currentObj.binSelector.enabled) { + var tab = getTabForSelector(this.id); + if (!isNull(tab)){ + return tab.projectConfig.binSize; + } else { + log("ERROR on getBinSize: Plot not attached to tab, Plot: " + this.id); + return null; + } + } else { + return currentObj.binSelector.value; } } diff --git a/src/main/resources/static/scripts/plots/rmsPlot.js b/src/main/resources/static/scripts/plots/rmsPlot.js index a04e446..6fa217f 100644 --- a/src/main/resources/static/scripts/plots/rmsPlot.js +++ b/src/main/resources/static/scripts/plots/rmsPlot.js @@ -51,18 +51,13 @@ function RmsPlot(id, plotConfig, getDataFromServerFn, onFiltersChangedFn, onPlot "From", "To", freqRange[0], freqRange[1], this.onFreqRangeValuesChanged, - null); - this.freqRangeSelector.step = getStepSizeFromRange(freqRange[1] - freqRange[0], 100); - this.freqRangeSelector.slider.slider({ - min: this.freqRangeSelector.fromValue, - max: this.freqRangeSelector.toValue, - values: [this.freqRangeSelector.fromValue, this.freqRangeSelector.toValue], - step: this.freqRangeSelector.step, - slide: function( event, ui ) { - currentObj.freqRangeSelector.setValues( ui.values[ 0 ], ui.values[ 1 ], "slider"); - currentObj.onFreqRangeValuesChanged(); - } - }); + null, + function( event, ui ) { + currentObj.freqRangeSelector.setValues( ui.values[ 0 ], ui.values[ 1 ], "slider"); + currentObj.onFreqRangeValuesChanged(); + }, + null, + getStepSizeFromRange(freqRange[1] - freqRange[0], 100)); this.freqRangeSelector.setEnabled(true); if (this.plotConfig.freq_range[0] > -1) { this.freqRangeSelector.setValues(this.plotConfig.freq_range[0], this.plotConfig.freq_range[1]); diff --git a/src/main/resources/static/scripts/projectConfig.js b/src/main/resources/static/scripts/projectConfig.js index 8716a54..f1605f4 100644 --- a/src/main/resources/static/scripts/projectConfig.js +++ b/src/main/resources/static/scripts/projectConfig.js @@ -45,14 +45,14 @@ function ProjectConfig(){ // Sets the total duration this.totalDuration = this.schema.getTotalDuration(); - // Sets the event count ratio - this.eventCountRatio = Math.min (CONFIG.MAX_PLOT_POINTS / this.schema.getEventsCount(), 1.0); - // Sets the time resolution this.minBinSize = this.schema.getTimeResolution(); this.maxBinSize = this.totalDuration / CONFIG.MIN_PLOT_POINTS; this.binSize = this.minBinSize; + // Sets the event count ratio + this.eventCountRatio = Math.min ((CONFIG.MAX_PLOT_POINTS / this.schema.getEventsCount()), 1.0); + //Sets the segment size for spectrums this.maxSegmentSize = this.schema.getMaxSegmentSize(); this.avgSegmentSize = this.schema.getAvgSegmentSize(); @@ -136,7 +136,7 @@ function ProjectConfig(){ } this.getMaxTimeRange = function () { - return this.totalDuration * this.eventCountRatio; + return this.totalDuration * this.binSize * this.eventCountRatio; } this.isMaxTimeRangeRatioFixed = function () { diff --git a/src/main/resources/static/scripts/schema.js b/src/main/resources/static/scripts/schema.js index fa2ebd0..377d8c3 100644 --- a/src/main/resources/static/scripts/schema.js +++ b/src/main/resources/static/scripts/schema.js @@ -93,7 +93,7 @@ function Schema(schema){ return 1.0; }*/ - return 1E-9; + return Math.pow(10, -CONFIG.MAX_TIME_RESOLUTION_DECIMALS); } this.getTotalDuration = function () { diff --git a/src/main/resources/static/scripts/selectors/binSelector.js b/src/main/resources/static/scripts/selectors/binSelector.js index 9efda8b..4f59611 100644 --- a/src/main/resources/static/scripts/selectors/binSelector.js +++ b/src/main/resources/static/scripts/selectors/binSelector.js @@ -1,5 +1,5 @@ -function BinSelector(id, title, fromLabel, fromValue, toValue, step, initValue, onSelectorValuesChangedFn, onSlideChanged) { +function BinSelector(id, title, fromLabel, fromValue, toValue, step, initValue, onSelectorValuesChangedFn, onSlideChanged, precision) { var currentObj = this; this.id = id.replace(/\./g,''); @@ -11,7 +11,7 @@ function BinSelector(id, title, fromLabel, fromValue, toValue, step, initValue, this.toValue = toValue; this.value = initValue; this.step = step; - this.precision = 3; + this.precision = !isNull(precision) ? precision : CONFIG.DEFAULT_NUMBER_DECIMALS; this.onSelectorValuesChanged = onSelectorValuesChangedFn; this.onSelectorEnabledChanged = null; @@ -57,7 +57,7 @@ function BinSelector(id, title, fromLabel, fromValue, toValue, step, initValue, //Set values method this.setValues = function (value, source) { - this.value = Math.min(Math.max(parseFloat(value), this.initFromValue), this.initToValue); + this.value = Math.min(Math.max(fixedPrecision(value, this.precision), this.initFromValue), this.initToValue); this.fromInput.val( fixedPrecision(this.value, this.precision) ).removeClass("wrongValue"); if (source != "slider") { this.slider.slider('values', 0, this.value); @@ -65,7 +65,7 @@ function BinSelector(id, title, fromLabel, fromValue, toValue, step, initValue, var tab = getTabForSelector(this.id); if (!isNull(tab)) { - tab.projectConfig.binSize = this.value; + tab.projectConfig.binSize = fixedPrecision(this.value, this.precision); if (tab.projectConfig.binSizeCouldHaveAliasing()) { this.showWarn("Aliasing/Moiré effects could arise"); } else { @@ -99,6 +99,11 @@ function BinSelector(id, title, fromLabel, fromValue, toValue, step, initValue, this.$html.find("h3").first().html(this.title + "( " + fixedPrecision(this.fromValue, this.precision) + " - " + fixedPrecision(this.toValue, this.precision) + " )"); } + this.setStep = function (step) { + this.step = step; + this.slider.slider("option", "step", this.step); + } + this.onSlideChanged = !isNull(onSlideChanged) ? onSlideChanged : function( event, ui ) { var sliderId = event.target.id.replace("slider-", ""); var tab = getTabForSelector(sliderId); @@ -135,3 +140,44 @@ function BinSelector(id, title, fromLabel, fromValue, toValue, step, initValue, return this; } + +//Caluculates intial, max, min and step values for bin size slider +function getBinSelectorConfig (projectConfig) { + + var minBinSize = 1; + var initValue = 1; + var step = 1; + var multiplier = 1; + + //If binSize is smaller than 1.0 find the divisor + while (projectConfig.maxBinSize * multiplier < 1) { + multiplier *= 10; + } + + var tmpStep = (1.0 / multiplier) / 100.0; + if ((projectConfig.maxBinSize / tmpStep) > CONFIG.MAX_PLOT_POINTS) { + //Fix step for not allowing more plot point than CONFIG.MAX_PLOT_POINTS + tmpStep = projectConfig.maxBinSize / CONFIG.MAX_PLOT_POINTS; + } + minBinSize = tmpStep; + step = minBinSize / 100.0; // We need at least 100 steps on slider + + if (projectConfig.minBinSize > 0) { + minBinSize = projectConfig.minBinSize; + var minAvailableBinSize = fixedPrecision(projectConfig.getMaxTimeRange() / CONFIG.MAX_PLOT_POINTS, CONFIG.MAX_TIME_RESOLUTION_DECIMALS); + if (CONFIG.AUTO_BINSIZE && (minAvailableBinSize > minBinSize)){ + minBinSize = minAvailableBinSize; + } + initValue = minBinSize; + step = minBinSize; + } else { + initValue = (projectConfig.maxBinSize - minBinSize) / 50; // Start initValue triying to plot at least 50 points + } + + return { + binSize: initValue, + minBinSize: minBinSize, + maxBinSize: projectConfig.maxBinSize, + step: step + }; +} diff --git a/src/main/resources/static/scripts/selectors/sliderSelector.js b/src/main/resources/static/scripts/selectors/sliderSelector.js index 8e85026..a41fdd9 100644 --- a/src/main/resources/static/scripts/selectors/sliderSelector.js +++ b/src/main/resources/static/scripts/selectors/sliderSelector.js @@ -1,5 +1,11 @@ -function sliderSelector(id, title, filterData, fromLabel, toLabel, fromValue, toValue, onSelectorValuesChangedFn, selectors_array, onSlideChanged) { +function sliderSelector(id, title, filterData, fromLabel, toLabel, fromValue, toValue, onSelectorValuesChangedFn, selectors_array, onSlideChanged, precision, fixed_step) { + + var thePrecision = !isNull(precision) ? precision : CONFIG.DEFAULT_NUMBER_DECIMALS; + if (!isNull(fixed_step)) { + var fsPrecision = getPrecisionFromFloat(fixed_step); + if (fsPrecision > thePrecision) { thePrecision = fsPrecision }; + } var currentObj = this; this.id = id.replace(/\./g,''); @@ -12,9 +18,9 @@ function sliderSelector(id, title, filterData, fromLabel, toLabel, fromValue, to this.fromValue = fromValue; this.toValue = toValue; this.maxRange = this.initToValue - this.initFromValue; - this.precision = 3; - this.fixed_step = null; // Sets the value step for snaping, fixed_step = 0.5 -> values: ... -1.0, -0.5, 0.0, 0.5, 1.0 ... - this.step = 1.0; + this.precision = thePrecision; + this.fixed_step = !isNull(fixed_step) ? fixed_step : null; // Sets the value step for snaping, fixed_step = 0.5 -> values: ... -1.0, -0.5, 0.0, 0.5, 1.0 ... + this.step = !isNull(fixed_step) ? fixed_step : 1.0; this.onSelectorValuesChanged = onSelectorValuesChangedFn; this.enabled = false; this.disableable = isNull(this.filterData.source); @@ -78,6 +84,7 @@ function sliderSelector(id, title, filterData, fromLabel, toLabel, fromValue, to range:true, min: this.fromValue, max: this.toValue, + step: this.step, values: [ fromValue, toValue ], slide: this.onSlideChanged }); diff --git a/src/main/resources/static/scripts/tabPanels/agnTabpanel.js b/src/main/resources/static/scripts/tabPanels/agnTabpanel.js index 91fcadd..200754b 100644 --- a/src/main/resources/static/scripts/tabPanels/agnTabpanel.js +++ b/src/main/resources/static/scripts/tabPanels/agnTabpanel.js @@ -41,6 +41,10 @@ function AGNTabPanel (id, classSelector, navItemClass, service, navBarList, pane if (!isNull(jsdata.abort)){ log("Current request aborted, AGNTabPanel: " + currentObj.id); + if (data.statusText == "error"){ + //If abort cause is because python server died + currentObj.outputPanel.setPlotsReadyState(true); + } return; //Comes from request abort call. } diff --git a/src/main/resources/static/scripts/tabPanels/pgTabpanel.js b/src/main/resources/static/scripts/tabPanels/pgTabpanel.js index e29cf71..2772c29 100644 --- a/src/main/resources/static/scripts/tabPanels/pgTabpanel.js +++ b/src/main/resources/static/scripts/tabPanels/pgTabpanel.js @@ -103,8 +103,9 @@ function PGTabPanel (id, classSelector, navItemClass, service, navBarList, panel function( event, ui ) { currentObj.freqRangeSelector.setValues( ui.values[ 0 ], ui.values[ 1 ], "slider"); currentObj.onFreqRangeValuesChanged(); - }); - this.freqRangeSelector.step = getStepSizeFromRange(freqRange[1] - freqRange[0], 100); + }, + null, + getStepSizeFromRange(freqRange[1] - freqRange[0], 100)); this.freqRangeSelector.setEnabled(true); this.onFreqRangeValuesChanged(); this.toolPanel.$html.find(".fileSelectorsContainer").append(this.freqRangeSelector.$html); @@ -159,6 +160,10 @@ function PGTabPanel (id, classSelector, navItemClass, service, navBarList, panel if (!isNull(jsdata.abort)){ log("Current request aborted, PgTabPanel: " + currentObj.id); + if (data.statusText == "error"){ + //If abort cause is because python server died + currentObj.outputPanel.setPlotsReadyState(true); + } return; //Comes from request abort call. } diff --git a/src/main/resources/static/scripts/tabPanels/phTabpanel.js b/src/main/resources/static/scripts/tabPanels/phTabpanel.js index ef18433..65257ab 100644 --- a/src/main/resources/static/scripts/tabPanels/phTabpanel.js +++ b/src/main/resources/static/scripts/tabPanels/phTabpanel.js @@ -165,8 +165,9 @@ function PHTabPanel (id, classSelector, navItemClass, service, navBarList, panel null, function( event, ui ) { currentObj.freqRangeSelector.setValues( ui.values[ 0 ], ui.values[ 1 ], "slider"); - }); - this.freqRangeSelector.step = getStepSizeFromRange(freqRange[1] - freqRange[0], 100); + }, + null, + getStepSizeFromRange(freqRange[1] - freqRange[0], 100)); this.freqRangeSelector.setEnabled(true); $pulseSearchContainer.append(this.freqRangeSelector.$html); @@ -355,6 +356,10 @@ function PHTabPanel (id, classSelector, navItemClass, service, navBarList, panel if (!isNull(jsdata.abort)){ log("Current request aborted, PhTabPanel: " + currentObj.id); + if (data.statusText == "error"){ + //If abort cause is because python server died + currentObj.outputPanel.setPlotsReadyState(true); + } return; //Comes from request abort call. } diff --git a/src/main/resources/static/scripts/tabPanels/settingsTabpanel.js b/src/main/resources/static/scripts/tabPanels/settingsTabpanel.js index b521086..8ea9169 100644 --- a/src/main/resources/static/scripts/tabPanels/settingsTabpanel.js +++ b/src/main/resources/static/scripts/tabPanels/settingsTabpanel.js @@ -55,6 +55,7 @@ function SettingsTabPanel (id, classSelector, navItemClass, service, navBarList, this.$container.find(".inputMAX_PLOT_POINTS").on('change', function(){ CONFIG.MAX_PLOT_POINTS = getInputIntValueCropped(currentObj.$container.find(".inputMAX_PLOT_POINTS"), CONFIG.MAX_PLOT_POINTS, CONFIG.MIN_PLOT_POINTS, 9999999); + updateServerConfig(); }); var $autoFilterRadios = this.$container.find(".autoFilterType").find("input[type=radio][name=" + this.id + "_AutoFilter]"); diff --git a/src/main/resources/static/scripts/tabPanels/wfTabpanel.js b/src/main/resources/static/scripts/tabPanels/wfTabpanel.js index 0d5142d..85e7f02 100644 --- a/src/main/resources/static/scripts/tabPanels/wfTabpanel.js +++ b/src/main/resources/static/scripts/tabPanels/wfTabpanel.js @@ -510,6 +510,7 @@ function WfTabPanel (id, classSelector, navItemClass, service, navBarList, panel this.onFiltersChangedFromPlot = function (filters) { log("onFiltersChangedFromPlot: filters: " + JSON.stringify(filters)); currentObj.toolPanel.applyFilters(filters); + currentObj.toolPanel.showPanel("filterPanel"); } this.onTimeRangeChanged = function (timeRange) { diff --git a/src/main/resources/static/scripts/tabPanels/xsTabpanel.js b/src/main/resources/static/scripts/tabPanels/xsTabpanel.js index ed3fffd..cb245ef 100644 --- a/src/main/resources/static/scripts/tabPanels/xsTabpanel.js +++ b/src/main/resources/static/scripts/tabPanels/xsTabpanel.js @@ -42,6 +42,10 @@ function XSTabPanel (id, classSelector, navItemClass, service, navBarList, panel if (!isNull(jsdata.abort)){ log("Current request aborted, XSTabPanel: " + currentObj.id); + if (data.statusText == "error"){ + //If abort cause is because python server died + currentObj.outputPanel.setPlotsReadyState(true); + } return; //Comes from request abort call. } diff --git a/src/main/resources/static/scripts/toolpanel.js b/src/main/resources/static/scripts/toolpanel.js index f1c20b0..80c44cb 100644 --- a/src/main/resources/static/scripts/toolpanel.js +++ b/src/main/resources/static/scripts/toolpanel.js @@ -216,7 +216,9 @@ function ToolPanel (id, this.removeSngOrMultiFileSelector(); this.resetFileSelectors("SRC"); - + + var excludedFilters = $.extend(true, [], CONFIG.EXCLUDED_FILTERS); + if (projectConfig.schema.isEventsFile()){ this.showEventsSelectors(); @@ -230,46 +232,28 @@ function ToolPanel (id, //PHA Column is empty, show we can't apply RMF file rmfMessage = "PHA column is empty in SRC file"; } - this.rmfFileSelector.disable(rmfMessage); - //Caluculates max, min and step values for slider with time ranges - var minBinSize = 1; - var initValue = 1; - var step = 1; - var multiplier = 1; - - //If binSize is smaller than 1.0 find the divisor - while (projectConfig.maxBinSize * multiplier < 1) { - multiplier *= 10; + if (rmfMessage != ""){ + //If hasen't PHA column then remove PI from excludedFilters + excludedFilters = excludedFilters.filter(function(column) { return column != "PI"; }); } + this.rmfFileSelector.disable(rmfMessage); - var tmpStep = (1.0 / multiplier) / 100.0; - if ((projectConfig.maxBinSize / tmpStep) > CONFIG.MAX_PLOT_POINTS) { - //Fix step for not allowing more plot point than CONFIG.MAX_PLOT_POINTS - tmpStep = projectConfig.maxBinSize / CONFIG.MAX_PLOT_POINTS; - } - minBinSize = tmpStep; - step = minBinSize / 100.0; // We need at least 100 steps on slider - - if (projectConfig.minBinSize > 0) { - minBinSize = projectConfig.minBinSize; - var minAvailableBinSize = projectConfig.getMaxTimeRange() / CONFIG.MAX_PLOT_POINTS; - if (CONFIG.AUTO_BINSIZE && (minAvailableBinSize > minBinSize)){ - minBinSize = minAvailableBinSize; - } - initValue = minBinSize; - step = minBinSize; - } else { - initValue = (projectConfig.maxBinSize - minBinSize) / 50; // Start initValue triying to plot at least 50 points - } + //Caluculates intial, max, min and step values for slider with time ranges + var binSelectorConfig = getBinSelectorConfig(projectConfig); - projectConfig.binSize = initValue; + projectConfig.binSize = binSelectorConfig.binSize; this.binSelector = new BinSelector(this.id + "_binSelector", "BIN SIZE (" + projectConfig.timeUnit + "):", "From", - minBinSize, projectConfig.maxBinSize, step, initValue, - this.onSelectorValuesChanged); + binSelectorConfig.minBinSize, + binSelectorConfig.maxBinSize, + binSelectorConfig.step, + binSelectorConfig.binSize, + this.onSelectorValuesChanged, + null, CONFIG.MAX_TIME_RESOLUTION_DECIMALS); + this.$html.find(".selectorsContainer").append(this.binSelector.$html); } else if (projectConfig.schema.isLightCurveFile()){ @@ -294,7 +278,7 @@ function ToolPanel (id, for (columnName in table) { var column = table[columnName]; - if (!CONFIG.EXCLUDED_FILTERS.includes(columnName) && column.min_value < column.max_value) { + if (!excludedFilters.includes(columnName) && column.min_value < column.max_value) { var filterData = { table:tableName, column:columnName }; var columnTitle = columnName + ":"; @@ -308,7 +292,8 @@ function ToolPanel (id, "From", "To", column.min_value, column.max_value, this.onSelectorValuesChanged, - this.selectors_array); + this.selectors_array, + null, CONFIG.MAX_TIME_RESOLUTION_DECIMALS); this.$html.find(".selectorsContainer").append(selector.$html); if ((columnName == "TIME") diff --git a/src/main/resources/static/styles/master_page.css b/src/main/resources/static/styles/master_page.css index 5123b4d..9fc0849 100644 --- a/src/main/resources/static/styles/master_page.css +++ b/src/main/resources/static/styles/master_page.css @@ -658,7 +658,7 @@ input.wrongValue { color: #007fff; } -.LogWarn, .LogServerWarn { +.LogWarn, .LogServerWarn, .Orange { color: #ff7d1b; } From b9ee3c5bef3e438ff03bade2dea9efe6dbcbab16 Mon Sep 17 00:00:00 2001 From: Ricardo Valles Blanco Date: Fri, 15 Sep 2017 00:28:44 +0200 Subject: [PATCH 02/10] DAVE-288: Fix python tests --- src/main/python/utils/dave_reader.py | 6 +++-- src/main/python/utils/file_utils.py | 23 +++++++++++-------- .../python/test/utils/test_dave_engine.py | 1 + 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/main/python/utils/dave_reader.py b/src/main/python/utils/dave_reader.py index 6c31e05..b81af7f 100644 --- a/src/main/python/utils/dave_reader.py +++ b/src/main/python/utils/dave_reader.py @@ -197,8 +197,10 @@ def get_events_fits_dataset_with_stingray(destination, hdulist, dsId='FITS', event_list, events_start_time = substract_tstart_from_events(fits_data, time_offset) - # Gets PI column data from eventlist if requiered and not in additional_data - if "PI" in additional_columns and "PI" not in fits_data.additional_data: + # Gets PI column data from eventlist if requiered and PHA not in additional_data + if "PI" in additional_columns \ + and "PI" not in fits_data.additional_data \ + and "PHA" not in fits_data.additional_data: fits_data.additional_data["PI"] = event_list.pi dataset = DataSet.get_dataset_applying_gtis(dsId, header, header_comments, diff --git a/src/main/python/utils/file_utils.py b/src/main/python/utils/file_utils.py index 010efa7..a6372b5 100644 --- a/src/main/python/utils/file_utils.py +++ b/src/main/python/utils/file_utils.py @@ -1,22 +1,27 @@ import os -import utils.dave_logger as logging import magic +import utils.dave_logger as logging +import utils.exception_helper as ExHelper from shutil import copyfile from werkzeug import secure_filename from config import CONFIG def get_destination(target, filename): - if CONFIG.IS_LOCAL_SERVER: - if filename.startswith('/') and os.path.isfile(filename): - # This is supposed to be an absolute path - return filename + try: + if CONFIG.IS_LOCAL_SERVER: + if filename.startswith('/') and os.path.isfile(filename): + # This is supposed to be an absolute path + return filename + else: + # Relative path + return "/".join([target, filename]) else: - # Relative path - return "/".join([target, filename]) - else: - return "/".join([target, secure_filename(filename)]) + return "/".join([target, secure_filename(filename)]) + except: + logging.error(ExHelper.getException('get_destination')) + return "" def file_exist(target, filename): return os.path.isfile(get_destination(target, filename)) diff --git a/src/test/python/test/utils/test_dave_engine.py b/src/test/python/test/utils/test_dave_engine.py index 7c67a6d..352a780 100644 --- a/src/test/python/test/utils/test_dave_engine.py +++ b/src/test/python/test/utils/test_dave_engine.py @@ -74,6 +74,7 @@ def test_get_power_density_spectrum(s): @given(text(min_size=1)) @example("test.evt") +@example("/\x00") def test_get_cross_spectrum(s): destination = FileUtils.get_destination(TEST_RESOURCES, s) result = None From 3bea026eba1d88d5ed5cfd0f2df8406c8293fc29 Mon Sep 17 00:00:00 2001 From: pbalm Date: Sun, 17 Sep 2017 14:47:57 +0200 Subject: [PATCH 03/10] Fixing command to install libmagic with MacPorts --- setup/setup.bash | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/setup/setup.bash b/setup/setup.bash index 4d69a1a..1a1d3e4 100755 --- a/setup/setup.bash +++ b/setup/setup.bash @@ -280,24 +280,24 @@ fi if [[ "$OSTYPE" == "darwin"* ]]; then - # Mac OSX - #This is for MagicFile but only applies to macosx - if [ ! -f /usr/local/bin/brew ]; then - if hash /opt/local/bin/port 2>/dev/null; then - echo "Installing LibMagic with MacPorts" - sudo /opt/local/bin/port install file - else - echo "Please install HomeBrew or MacPorts before continue." - echo "Run this HomeBrew installation command on a terminal and relanch DAVE:" - echo '/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"' - echo "Or install MacPorts with this guide:" - echo 'https://www.macports.org/install.php' - exit 1 - fi - else - echo "Installing LibMagic with HomeBrew" - /usr/local/bin/brew install libmagic - fi + # Mac OSX + # This is for MagicFile but only applies to macosx + if [ ! -f /usr/local/bin/brew ]; then + if hash /opt/local/bin/port 2>/dev/null; then + echo "Installing LibMagic with MacPorts" + yes | sudo /opt/local/bin/port install libmagic + else + echo "Please install HomeBrew or MacPorts before continue." + echo "Run this HomeBrew installation command on a terminal and relanch DAVE:" + echo '/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"' + echo "Or install MacPorts with this guide:" + echo 'https://www.macports.org/install.php' + exit 1 + fi + else + echo "Installing LibMagic with HomeBrew" + /usr/local/bin/brew install libmagic + fi fi From ab0163b098ee654b4e725a9f34076204fc00c40b Mon Sep 17 00:00:00 2001 From: Ricardo Valles Blanco Date: Sun, 17 Sep 2017 19:34:44 +0200 Subject: [PATCH 04/10] Removed Independent files loading --- .../static/scripts/tabPanels/wfTabpanel.js | 53 +++++-------- .../resources/static/scripts/toolpanel.js | 74 +++++-------------- 2 files changed, 35 insertions(+), 92 deletions(-) diff --git a/src/main/resources/static/scripts/tabPanels/wfTabpanel.js b/src/main/resources/static/scripts/tabPanels/wfTabpanel.js index 85e7f02..6964663 100644 --- a/src/main/resources/static/scripts/tabPanels/wfTabpanel.js +++ b/src/main/resources/static/scripts/tabPanels/wfTabpanel.js @@ -79,39 +79,26 @@ function WfTabPanel (id, classSelector, navItemClass, service, navBarList, panel } else if (filenames.length > 1){ - if (currentObj.toolPanel.loadFileType == "Independent") { - - //Load an independent tab for each file - for (idx in filenames){ - var file = filenames[idx]; - openIndependentFileTab(file); - } - //Removes this tab - removeTab(currentObj.id); - - } else { - - //Concatenate all files - currentObj.projectConfig.setFiles(selectorKey, filenames, filenames[0]); - var params = {}; - if (selectorKey == "SRC") { - params = { filename: currentObj.projectConfig.filename, filenames: currentObj.projectConfig.filenames, currentFile: 1, onSchemaChanged:currentObj.onSrcSchemaChanged }; - } else if (selectorKey == "BCK") { - params = { filename: currentObj.projectConfig.bckFilename, filenames: currentObj.projectConfig.bckFilenames, currentFile: 1, onSchemaChanged:currentObj.onBckSchemaChanged }; - } else if (selectorKey == "GTI") { - params = { filename: currentObj.projectConfig.gtiFilename, filenames: currentObj.projectConfig.gtiFilenames, currentFile: 1, onSchemaChanged:currentObj.onGtiSchemaChanged }; - } else if (selectorKey == "RMF") { - log("onDatasetChanged: RMF files doesn't support multiple selection!"); - return; - } - - if (!isNull(callback)){ - params.callback = callback; - } + //Concatenate all files + currentObj.projectConfig.setFiles(selectorKey, filenames, filenames[0]); + var params = {}; + if (selectorKey == "SRC") { + params = { filename: currentObj.projectConfig.filename, filenames: currentObj.projectConfig.filenames, currentFile: 1, onSchemaChanged:currentObj.onSrcSchemaChanged }; + } else if (selectorKey == "BCK") { + params = { filename: currentObj.projectConfig.bckFilename, filenames: currentObj.projectConfig.bckFilenames, currentFile: 1, onSchemaChanged:currentObj.onBckSchemaChanged }; + } else if (selectorKey == "GTI") { + params = { filename: currentObj.projectConfig.gtiFilename, filenames: currentObj.projectConfig.gtiFilenames, currentFile: 1, onSchemaChanged:currentObj.onGtiSchemaChanged }; + } else if (selectorKey == "RMF") { + log("onDatasetChanged: RMF files doesn't support multiple selection!"); + return; + } - currentObj.onSchemaChangedMultipleFiles(null, params); + if (!isNull(callback)){ + params.callback = callback; } + currentObj.onSchemaChangedMultipleFiles(null, params); + } else { log("onDatasetChanged " + selectorKey + ": No selected files.."); @@ -791,9 +778,3 @@ function WfTabPanel (id, classSelector, navItemClass, service, navBarList, panel return this; } - -function openIndependentFileTab (filename) { - var tab = addWfTabPanel($("#navbar").find("ul").first(), $(".daveContainer")); - tab.toolPanel.srcFileSelector.onUploadSuccess([filename]); - tab.onDatasetChanged([filename], "SRC"); -} diff --git a/src/main/resources/static/scripts/toolpanel.js b/src/main/resources/static/scripts/toolpanel.js index 80c44cb..c41948c 100644 --- a/src/main/resources/static/scripts/toolpanel.js +++ b/src/main/resources/static/scripts/toolpanel.js @@ -18,7 +18,7 @@ function ToolPanel (id, container.html(this.$html); this.$html.show(); this.filters = []; - this.loadFileType = "Single"; // Supported: Single, Concatenated, Independent + this.loadFileType = "Single"; // Supported: Single, Concatenated this.buttonsContainer = this.$html.find(".buttonsContainer"); this.analyzeContainer = this.$html.find(".analyzeContainer"); @@ -131,66 +131,28 @@ function ToolPanel (id, this.createSngOrMultiFileSelector = function () { // Creates Single file or Multifile selection radio buttons - this.sngOrMultiFileSelector = $('
' + - '

Choose single or multiple files load:

' + - '
' + - '' + - '' + - '' + - '' + - '
' + - '
'); - + this.sngOrMultiFileSelector = getRadioControl(this.id, + "Choose single or multiple files load", + "SngOrMultiFile", + [ + { id:"SngFile", label:"Single file", value:"Single"}, + { id:"ConFile", label:"Multiple files", value:"Concatenated"} + ], + "Single", + function(value, id) { + currentObj.loadFileType = value; + for (idx in currentObj.file_selectors_array) { + var fileSelector = currentObj.file_selectors_array[idx]; + fileSelector.setMultiFileEnabled(value != "Single" + && (fileSelector.selectorKey != "RMF") + && (!fileSelector.selectorKey.startsWith("LC"))); + } + }); this.$html.find(".fileSelectorsContainer").append(this.sngOrMultiFileSelector); - var $loadTypeRadios = this.sngOrMultiFileSelector.find("input[type=radio][name=" + this.id + "_SngOrMultiFile]") - $loadTypeRadios.checkboxradio(); - this.sngOrMultiFileSelector.find("fieldset").controlgroup(); - $loadTypeRadios.change(function() { - currentObj.updateLoadFileType(); - var multiFileEnabled = currentObj.loadFileType != "Single"; - setVisibility(currentObj.conOrIndFileSelector, multiFileEnabled); - for (idx in currentObj.file_selectors_array) { - var fileSelector = currentObj.file_selectors_array[idx]; - fileSelector.setMultiFileEnabled(multiFileEnabled - && (fileSelector.selectorKey != "RMF") - && (!fileSelector.selectorKey.startsWith("LC"))); - } - }); - - // Creates Concatenated files or Independent selection radio buttons - this.conOrIndFileSelector = $('
' + - '

Choose concatenated or independent files load:

' + - '
' + - '' + - '' + - '' + - '' + - '
' + - '
'); - - setVisibility(this.conOrIndFileSelector, this.loadFileType == "Multi"); - this.$html.find(".fileSelectorsContainer").append(this.conOrIndFileSelector); - var $loadType2Radios = this.conOrIndFileSelector.find("input[type=radio][name=" + this.id + "_ConOrIndFile]") - $loadType2Radios.checkboxradio(); - this.conOrIndFileSelector.find("fieldset").controlgroup(); - $loadType2Radios.change(function() { - currentObj.updateLoadFileType(); - }); - } - - this.updateLoadFileType = function () { - if (this.sngOrMultiFileSelector.find("input").filter('[value=Single]').prop('checked')) { - this.loadFileType = "Single"; - } else if (this.conOrIndFileSelector.find("input").filter('[value=Concatenated]').prop('checked')) { - this.loadFileType = "Concatenated"; - } else { - this.loadFileType = "Independent"; - } } this.removeSngOrMultiFileSelector = function () { this.sngOrMultiFileSelector.remove(); - this.conOrIndFileSelector.remove(); } this.onTimeRangeChanged = function (timeRange) { From 7116313fef6fd8eae9d10f86e7392e30eb3a4ecb Mon Sep 17 00:00:00 2001 From: Ricardo Valles Blanco Date: Sun, 17 Sep 2017 20:27:37 +0200 Subject: [PATCH 05/10] DAVE-300: Removed restrictions to only show 1000 points on plots --- src/main/python/utils/dave_engine.py | 15 ++++++++------- .../static/scripts/selectors/binSelector.js | 7 ++++--- .../static/scripts/tabPanels/settingsTabpanel.js | 8 ++++---- src/main/resources/static/scripts/toolpanel.js | 7 ++++--- 4 files changed, 20 insertions(+), 17 deletions(-) diff --git a/src/main/python/utils/dave_engine.py b/src/main/python/utils/dave_engine.py index 76a9672..297fab9 100644 --- a/src/main/python/utils/dave_engine.py +++ b/src/main/python/utils/dave_engine.py @@ -648,7 +648,7 @@ def get_dynamical_spectrum(src_destination, bck_destination, gti_destination, if pds: - pds = rebin_spectrum_if_necessary(pds) + #pds = rebin_spectrum_if_necessary(pds) freq = pds.freq @@ -1152,7 +1152,7 @@ def get_rms_spectrum(src_destination, bck_destination, gti_destination, if pds: - pds = rebin_spectrum_if_necessary(pds) + #pds = rebin_spectrum_if_necessary(pds) if freq_range[0] < 0: freq_low = min(pds.freq) @@ -1475,7 +1475,7 @@ def get_bootstrap_results(src_destination, bck_destination, gti_destination, sim_pds = AveragedPowerspectrum(lc=sim_lc, segment_size=segm_size, norm=norm, gti=gti) if sim_pds: - sim_pds = rebin_spectrum_if_necessary(sim_pds) + #sim_pds = rebin_spectrum_if_necessary(sim_pds) parest, res = fit_powerspectrum(sim_pds, fit_model, starting_pars, max_post=False, priors=None, fitmethod="L-BFGS-B") @@ -2005,14 +2005,15 @@ def create_power_density_spectrum(src_destination, bck_destination, gti_destinat else: pds = AveragedPowerspectrum(lc=lc, segment_size=segm_size, norm=norm, gti=gti) - if pds: - pds = rebin_spectrum_if_necessary(pds) - else: - logging.warn("Can't create power spectrum") + #if pds: + # pds = rebin_spectrum_if_necessary(pds) + #else: + # logging.warn("Can't create power spectrum") return pds, lc, gti +# Reduces the pds data to Max_plot_points for improve pds performance def rebin_spectrum_if_necessary (pds): freq_size = len(pds.freq) if freq_size > CONFIG.MAX_PLOT_POINTS: diff --git a/src/main/resources/static/scripts/selectors/binSelector.js b/src/main/resources/static/scripts/selectors/binSelector.js index 4f59611..7ebc656 100644 --- a/src/main/resources/static/scripts/selectors/binSelector.js +++ b/src/main/resources/static/scripts/selectors/binSelector.js @@ -164,11 +164,12 @@ function getBinSelectorConfig (projectConfig) { if (projectConfig.minBinSize > 0) { minBinSize = projectConfig.minBinSize; - var minAvailableBinSize = fixedPrecision(projectConfig.getMaxTimeRange() / CONFIG.MAX_PLOT_POINTS, CONFIG.MAX_TIME_RESOLUTION_DECIMALS); + var minAvailableBinSize = fixedPrecision(projectConfig.totalDuration / CONFIG.MAX_PLOT_POINTS, CONFIG.MAX_TIME_RESOLUTION_DECIMALS); if (CONFIG.AUTO_BINSIZE && (minAvailableBinSize > minBinSize)){ - minBinSize = minAvailableBinSize; + initValue = minAvailableBinSize; + } else { + initValue = minBinSize; } - initValue = minBinSize; step = minBinSize; } else { initValue = (projectConfig.maxBinSize - minBinSize) / 50; // Start initValue triying to plot at least 50 points diff --git a/src/main/resources/static/scripts/tabPanels/settingsTabpanel.js b/src/main/resources/static/scripts/tabPanels/settingsTabpanel.js index 8ea9169..28aa836 100644 --- a/src/main/resources/static/scripts/tabPanels/settingsTabpanel.js +++ b/src/main/resources/static/scripts/tabPanels/settingsTabpanel.js @@ -31,7 +31,7 @@ function SettingsTabPanel (id, classSelector, navItemClass, service, navBarList, '
' + '

Minimum points to plot:

' + '

Maximum points to plot:

' + - '
' + + /*'
' + '

Auto Filtering:' + '

' + '' + @@ -39,7 +39,7 @@ function SettingsTabPanel (id, classSelector, navItemClass, service, navBarList, '' + '' + '

' + - '

' + + '
' +*/ '
' + '

' + 'Power density spectrum settings:' + @@ -58,12 +58,12 @@ function SettingsTabPanel (id, classSelector, navItemClass, service, navBarList, updateServerConfig(); }); - var $autoFilterRadios = this.$container.find(".autoFilterType").find("input[type=radio][name=" + this.id + "_AutoFilter]"); + /*var $autoFilterRadios = this.$container.find(".autoFilterType").find("input[type=radio][name=" + this.id + "_AutoFilter]"); $autoFilterRadios.checkboxradio(); this.$container.find(".autoFilterType").find("fieldset").controlgroup(); $autoFilterRadios.change(function() { CONFIG.AUTO_BINSIZE = this.value == "BinSize"; - }); + });*/ this.$container.find(".inputMIN_SEGMENT_MULTIPLIER").on('change', function(){ CONFIG.MIN_SEGMENT_MULTIPLIER = getInputIntValueCropped(currentObj.$container.find(".inputMIN_SEGMENT_MULTIPLIER"), CONFIG.MIN_SEGMENT_MULTIPLIER, 1, 100); diff --git a/src/main/resources/static/scripts/toolpanel.js b/src/main/resources/static/scripts/toolpanel.js index c41948c..c15d1b4 100644 --- a/src/main/resources/static/scripts/toolpanel.js +++ b/src/main/resources/static/scripts/toolpanel.js @@ -156,14 +156,14 @@ function ToolPanel (id, } this.onTimeRangeChanged = function (timeRange) { - if (CONFIG.AUTO_BINSIZE && !isNull(this.binSelector)){ + /*if (CONFIG.AUTO_BINSIZE && !isNull(this.binSelector)){ var tab = getTabForSelector(this.id); if (!isNull(tab)){ var minValue = Math.max(timeRange / CONFIG.MAX_PLOT_POINTS, tab.projectConfig.minBinSize); var maxValue = Math.max(Math.min(timeRange / CONFIG.MIN_PLOT_POINTS, tab.projectConfig.maxBinSize), minValue * CONFIG.MIN_PLOT_POINTS); this.binSelector.setMinMaxValues(minValue, maxValue); } - } + }*/ } this.onDatasetSchemaChanged = function ( projectConfig ) { @@ -263,7 +263,8 @@ function ToolPanel (id, && projectConfig.isMaxTimeRangeRatioFixed()) { //If full events were cropped to CONFIG.MAX_PLOT_POINTS - selector.setMaxRange(projectConfig.getMaxTimeRange()); + //selector.setMaxRange(projectConfig.getMaxTimeRange()); + selector.setValues( selector.initFromValue, selector.initFromValue + projectConfig.getMaxTimeRange() ); selector.setEnabled (true); } From 45ab4469e8807626c20f7bb5c4c5956d8ee112bb Mon Sep 17 00:00:00 2001 From: Ricardo Valles Blanco Date: Sun, 17 Sep 2017 21:43:24 +0200 Subject: [PATCH 06/10] DAVE-301: segment length as small as binsize, and some code refactor --- src/main/resources/static/scripts/config.js | 2 +- .../resources/static/scripts/htmlControls.js | 4 +- .../static/scripts/plots/dynSpPlot.js | 4 +- .../resources/static/scripts/plots/pdsPlot.js | 136 +++++++++--------- .../static/scripts/plots/plotWithSettings.js | 82 +++++------ 5 files changed, 103 insertions(+), 125 deletions(-) diff --git a/src/main/resources/static/scripts/config.js b/src/main/resources/static/scripts/config.js index 6aea3fd..19e7b86 100644 --- a/src/main/resources/static/scripts/config.js +++ b/src/main/resources/static/scripts/config.js @@ -7,7 +7,7 @@ CONFIG = { MIN_PLOT_POINTS: 2, MAX_PLOT_POINTS: 1000, AUTO_BINSIZE: true, //If AUTO_BINSIZE is enabled, then the binSize will be automatically calculated to avoid exceding MAX_PLOT_POINTS, else the time filter will have a maxTimeRange to avoid exeding the MAX_PLOT_POINTS - MIN_SEGMENT_MULTIPLIER: 6, + MIN_SEGMENT_MULTIPLIER: 1, DEFAULT_SEGMENT_DIVIDER: 4, PLOT_ENABLE_HOVER_TIMEOUT: 1000, PLOT_TRIGGER_HOVER_TIMEOUT: 250, diff --git a/src/main/resources/static/scripts/htmlControls.js b/src/main/resources/static/scripts/htmlControls.js index b976985..c64c4c2 100644 --- a/src/main/resources/static/scripts/htmlControls.js +++ b/src/main/resources/static/scripts/htmlControls.js @@ -125,8 +125,8 @@ function getSectionContainer ($section){ return $section.find(".sectionContainer").first(); } -function getRadioControl (id, title, cssClass, options, selectedValue, onChangeFn){ - var radioName = id + "_" + cssClass; +function getRadioControl (containerId, title, cssClass, options, selectedValue, onChangeFn){ + var radioName = containerId + "_" + cssClass; var $radiosCont = $('
' + '

' + title + ':

' + '
' + diff --git a/src/main/resources/static/scripts/plots/dynSpPlot.js b/src/main/resources/static/scripts/plots/dynSpPlot.js index 46302e6..fc540f8 100644 --- a/src/main/resources/static/scripts/plots/dynSpPlot.js +++ b/src/main/resources/static/scripts/plots/dynSpPlot.js @@ -25,7 +25,7 @@ function DynSpPlot(id, plotConfig, getDataFromServerFn, onFiltersChangedFn, onPl }); //If plot is pds adds Fits button to plot - this.btnStyle = $(''); + this.btnStyle = $(''); this.$html.find(".plotTools").prepend(this.btnStyle); this.btnStyle.click(function(event){ if (currentObj.plotConfig.plotStyle == "3d") { @@ -47,6 +47,8 @@ function DynSpPlot(id, plotConfig, getDataFromServerFn, onFiltersChangedFn, onPl this.onBinSizeChanged = function () { currentObj.plotConfig.dt = currentObj.binSelector.value; + var segmConfig = this.getSegmSelectorConfig(); + currentObj.segmSelector.setMinMaxValues(segmConfig.minValue, segmConfig.maxValue, segmConfig.step); currentObj.updateSegmSelector(); currentObj.updateMaxMinFreq(true); if (!isNull(currentObj.freqSelector)) { diff --git a/src/main/resources/static/scripts/plots/pdsPlot.js b/src/main/resources/static/scripts/plots/pdsPlot.js index 5095f9c..1440545 100644 --- a/src/main/resources/static/scripts/plots/pdsPlot.js +++ b/src/main/resources/static/scripts/plots/pdsPlot.js @@ -46,40 +46,28 @@ function PDSPlot(id, plotConfig, getDataFromServerFn, onFiltersChangedFn, onPlot if (isNull(this.plotConfig.styles.showPdsType) || this.plotConfig.styles.showPdsType){ // Creates PDS type radio buttons - this.typeRadios = $('
' + - '

PDS Type:

' + - '
' + - '' + - '' + - '' + - '' + - '
' + - '
'); - + this.typeRadios = getRadioControl(this.id, + 'PDS Type', + "pdsType", + [ + { id:"Sng", label:"Single", value:"Sng"}, + { id:"Avg", label:"Averaged", value:"Avg"} + ], + this.plotConfig.type, + function(value, id) { + currentObj.plotConfig.type = value; + setVisibility(currentObj.segmSelector.$html, value != "Sng"); + }); this.settingsPanel.find(".leftCol").append(this.typeRadios); - var $typeRadios = this.typeRadios.find("input[type=radio][name=" + this.id + "_Type]") - $typeRadios.checkboxradio(); - this.typeRadios.find("fieldset").controlgroup(); - $typeRadios.change(function() { - currentObj.plotConfig.type = this.value; - setVisibility(currentObj.segmSelector.$html, currentObj.plotConfig.type != "Sng"); - }); } // Creates the Segment length selector var tab = getTabForSelector(this.id); - var binSize = this.getBinSize(); - var segmSize = this.plotConfig.segment_size; - var minValue = binSize * CONFIG.MIN_SEGMENT_MULTIPLIER; - var maxValue = (this.plotConfig.maxSegmentSize > 0) ? this.plotConfig.maxSegmentSize : segmSize * 100; - if (this.plotConfig.duration > 0) { - maxValue = Math.min(maxValue, this.plotConfig.duration); - } - + var segmConfig = this.getSegmSelectorConfig(); this.segmSelector = new BinSelector(this.id + "_segmSelector", "Segment Length (" + tab.projectConfig.timeUnit + "):", "From", - minValue, maxValue, binSize, segmSize, + segmConfig.minValue, segmConfig.maxValue, segmConfig.step, segmConfig.initValue, this.onSegmSelectorValuesChanged, function( event, ui ) { currentObj.segmSelector.setValues( ui.values[ 0 ], "slider"); @@ -96,39 +84,31 @@ function PDSPlot(id, plotConfig, getDataFromServerFn, onFiltersChangedFn, onPlot } // Creates the Normalization radio buttons - this.normRadios = $('
' + - '

Normalization:

' + - '
' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '
' + - '
'); - + this.normRadios = getRadioControl(this.id, + 'Normalization', + "pdsNorm", + [ + { id:"leahy", label:"Leahy", value:"leahy"}, + { id:"frac", label:"Frac", value:"frac"}, + { id:"abs", label:"Abs", value:"abs"}, + { id:"none", label:"None", value:"none"} + ], + this.plotConfig.norm, + function(value, id) { + currentObj.plotConfig.norm = value; + }); this.settingsPanel.find(".leftCol").append(this.normRadios); - var $normRadios = this.normRadios.find("input[type=radio][name=" + this.id + "norm]") - $normRadios.checkboxradio(); - this.normRadios.find("fieldset").controlgroup(); - $normRadios.change(function() { - currentObj.plotConfig.norm = this.value; - }); - // Creates the Plot Binnin Size selector this.rebinSelector = new BinSelector(this.id + "_rebinSelector", - "Binning (Freq):", - "From", - this.plotConfig.minRebinSize, this.plotConfig.maxRebinSize, this.plotConfig.minRebinSize, this.plotConfig.rebinSize, - this.onBinSelectorValuesChanged, - function( event, ui ) { - currentObj.rebinSelector.setValues( ui.values[ 0 ], "slider"); - currentObj.onBinSelectorValuesChanged(); - }); + "Binning (Freq):", + "From", + this.plotConfig.minRebinSize, this.plotConfig.maxRebinSize, this.plotConfig.minRebinSize, this.plotConfig.rebinSize, + this.onBinSelectorValuesChanged, + function( event, ui ) { + currentObj.rebinSelector.setValues( ui.values[ 0 ], "slider"); + currentObj.onBinSelectorValuesChanged(); + }); this.rebinSelector.setDisableable(true); this.rebinSelector.setEnabled(currentObj.plotConfig.rebinEnabled); this.rebinSelector.switchBox.click( function ( event ) { @@ -144,28 +124,39 @@ function PDSPlot(id, plotConfig, getDataFromServerFn, onFiltersChangedFn, onPlot this.addAxesTypeControlsToSettings(".rightCol"); // Creates the plot type radio buttons - this.plotTypeRadios = $('
' + - '

' + currentObj.plotConfig.styles.labels[!isNull(this.plotConfig.zAxisType) ? 2 : 1] + ' axis data:

' + - '
' + - '' + - '' + - '' + - '' + - '
' + - '
'); - + this.plotTypeRadios = getRadioControl(this.id, + this.plotConfig.styles.labels[!isNull(this.plotConfig.zAxisType) ? 2 : 1] + ' axis data', + "pdsPlotType", + [ + { id:"TypeXY", label:"Power x Frequency", value:"X*Y"}, + { id:"TypeX", label:"Power", value:"X"} + ], + this.plotConfig.plotType, + function(value, id) { + currentObj.plotConfig.plotType = value; + }); this.settingsPanel.find(".rightCol").append(this.plotTypeRadios); - var $plotTypeRadios = this.plotTypeRadios.find("input[type=radio][name=" + this.id + "PlotType]") - $plotTypeRadios.checkboxradio(); - this.plotTypeRadios.find("fieldset").controlgroup(); - $plotTypeRadios.change(function() { - currentObj.plotConfig.plotType = this.value; - }); this.onSettingsCreated(); } } + this.getSegmSelectorConfig = function () { + var binSize = this.getBinSize(); + var segmSize = this.plotConfig.segment_size; + var minValue = binSize * CONFIG.MIN_SEGMENT_MULTIPLIER; + var maxValue = (this.plotConfig.maxSegmentSize > 0) ? this.plotConfig.maxSegmentSize : segmSize * 100; + if (this.plotConfig.duration > 0) { + maxValue = Math.min(maxValue, this.plotConfig.duration); + } + + return { initValue: segmSize, + minValue: minValue, + maxValue: maxValue, + step: binSize + } + } + this.updateSettings = function(){ if (this.settingsPanel.find(".pdsNorm").length > 0) { @@ -199,7 +190,6 @@ function PDSPlot(id, plotConfig, getDataFromServerFn, onFiltersChangedFn, onPlot this.updateSegmSelector = function () { var tab = getTabForSelector(currentObj.id); currentObj.segmSelector.setTitle("Segment Length (" + tab.projectConfig.timeUnit + "): Nº Segments= " + fixedPrecision(currentObj.plotConfig.nsegm, 2) + ""); - currentObj.segmSelector.setStep(this.getBinSize()); if (Math.floor(currentObj.plotConfig.nsegm) <= 1){ //If NSegm = 1, set normalization to leahy @@ -210,6 +200,8 @@ function PDSPlot(id, plotConfig, getDataFromServerFn, onFiltersChangedFn, onPlot this.onBinSizeChanged = function () { currentObj.plotConfig.dt = currentObj.binSelector.value; + var segmConfig = this.getSegmSelectorConfig(); + currentObj.segmSelector.setMinMaxValues(segmConfig.minValue, segmConfig.maxValue, segmConfig.step); currentObj.updateSegmSelector(); } diff --git a/src/main/resources/static/scripts/plots/plotWithSettings.js b/src/main/resources/static/scripts/plots/plotWithSettings.js index 2222ac4..f684252 100644 --- a/src/main/resources/static/scripts/plots/plotWithSettings.js +++ b/src/main/resources/static/scripts/plots/plotWithSettings.js @@ -109,63 +109,47 @@ function PlotWithSettings(id, plotConfig, getDataFromServerFn, onFiltersChangedF this.addAxesTypeControlsToSettings = function (columnClass) { if (!isNull(this.plotConfig.xAxisType) && !isNull(this.plotConfig.yAxisType)) { - // Creates the X axis type radio buttons - this.xAxisRadios = $('
' + - '

' + currentObj.plotConfig.styles.labels[0] + ' axis type:

' + - '
' + - '' + - '' + - '' + - '' + - '
' + - '
'); + var options = [ + { id:"linear", label:"Linear", value:"linear"}, + { id:"log", label:"Logarithmic", value:"log"} + ]; + // Creates the X axis type radio buttons + this.xAxisRadios = getRadioControl(this.id, + this.plotConfig.styles.labels[0] + ' axis type', + "pdsXAxisType", + options, + this.plotConfig.xAxisType, + function(value, id) { + currentObj.plotConfig.xAxisType = value; + }); + this.xAxisRadios.addClass("AxisType"); this.settingsPanel.find(columnClass).append(this.xAxisRadios); - var $xAxisRadios = this.xAxisRadios.find("input[type=radio][name=" + this.id + "XAxisType]") - $xAxisRadios.checkboxradio(); - this.xAxisRadios.find("fieldset").controlgroup(); - $xAxisRadios.change(function() { - currentObj.plotConfig.xAxisType = this.value; - }); // Creates the Y axis type radio buttons - this.yAxisRadios = $('
' + - '

' + currentObj.plotConfig.styles.labels[1] + ' axis type:

' + - '
' + - '' + - '' + - '' + - '' + - '
' + - '
'); - + this.yAxisRadios = getRadioControl(this.id, + this.plotConfig.styles.labels[1] + ' axis type', + "pdsYAxisType", + options, + this.plotConfig.yAxisType, + function(value, id) { + currentObj.plotConfig.yAxisType = value; + }); + this.yAxisRadios.addClass("AxisType"); this.settingsPanel.find(columnClass).append(this.yAxisRadios); - var $yAxisRadios = this.yAxisRadios.find("input[type=radio][name=" + this.id + "YAxisType]") - $yAxisRadios.checkboxradio(); - this.yAxisRadios.find("fieldset").controlgroup(); - $yAxisRadios.change(function() { - currentObj.plotConfig.yAxisType = this.value; - }); if (!isNull(this.plotConfig.zAxisType)) { - // Creates the X axis type radio buttons - this.zAxisRadios = $('
' + - '

' + currentObj.plotConfig.styles.labels[2] + ' axis type:

' + - '
' + - '' + - '' + - '' + - '' + - '
' + - '
'); - + // Creates the Z axis type radio buttons + this.zAxisRadios = getRadioControl(this.id, + this.plotConfig.styles.labels[2] + ' axis type', + "pdsZAxisType", + options, + this.plotConfig.zAxisType, + function(value, id) { + currentObj.plotConfig.zAxisType = value; + }); + this.zAxisRadios.addClass("AxisType"); this.settingsPanel.find(columnClass).append(this.zAxisRadios); - var $zAxisRadios = this.zAxisRadios.find("input[type=radio][name=" + this.id + "ZAxisType]") - $zAxisRadios.checkboxradio(); - this.zAxisRadios.find("fieldset").controlgroup(); - $zAxisRadios.change(function() { - currentObj.plotConfig.zAxisType = this.value; - }); } } else { From dcf2c3eae1cff2e19bef6350288b56a1d0dfb58a Mon Sep 17 00:00:00 2001 From: Ricardo Valles Blanco Date: Mon, 18 Sep 2017 13:28:49 +0200 Subject: [PATCH 07/10] Add warning message when more than MAX_PLOT_POINTS will be plotted --- src/main/resources/static/scripts/config.js | 1 + .../resources/static/scripts/projectConfig.js | 18 +++++ src/main/resources/static/scripts/schema.js | 2 +- .../static/scripts/selectors/binSelector.js | 16 ++--- .../scripts/selectors/sliderSelector.js | 29 +++------ .../static/scripts/tabPanels/wfTabpanel.js | 9 +-- .../resources/static/scripts/toolpanel.js | 65 +++++++++++++++---- .../resources/static/styles/master_page.css | 4 ++ 8 files changed, 97 insertions(+), 47 deletions(-) diff --git a/src/main/resources/static/scripts/config.js b/src/main/resources/static/scripts/config.js index 19e7b86..a233afc 100644 --- a/src/main/resources/static/scripts/config.js +++ b/src/main/resources/static/scripts/config.js @@ -8,6 +8,7 @@ CONFIG = { MAX_PLOT_POINTS: 1000, AUTO_BINSIZE: true, //If AUTO_BINSIZE is enabled, then the binSize will be automatically calculated to avoid exceding MAX_PLOT_POINTS, else the time filter will have a maxTimeRange to avoid exeding the MAX_PLOT_POINTS MIN_SEGMENT_MULTIPLIER: 1, + TIMERANGE_MULTIPLIER: 0.95, DEFAULT_SEGMENT_DIVIDER: 4, PLOT_ENABLE_HOVER_TIMEOUT: 1000, PLOT_TRIGGER_HOVER_TIMEOUT: 250, diff --git a/src/main/resources/static/scripts/projectConfig.js b/src/main/resources/static/scripts/projectConfig.js index f1605f4..3364f50 100644 --- a/src/main/resources/static/scripts/projectConfig.js +++ b/src/main/resources/static/scripts/projectConfig.js @@ -135,6 +135,20 @@ function ProjectConfig(){ return this.binSize != this.minBinSize && this.binSize < (this.minBinSize * 2.0); } + this.setTimeRange = function (timeRange) { + this.timeRange = timeRange; + this.maxSegmentSize = timeRange * CONFIG.TIMERANGE_MULTIPLIER; + this.avgSegmentSize = this.maxSegmentSize / CONFIG.DEFAULT_SEGMENT_DIVIDER; + } + + this.getTimeRange = function () { + if (!isNull(this.timeRange)) { + return this.timeRange; + } else { + return this.totalDuration; + } + } + this.getMaxTimeRange = function () { return this.totalDuration * this.binSize * this.eventCountRatio; } @@ -143,6 +157,10 @@ function ProjectConfig(){ return this.eventCountRatio < 1.0; } + this.getNumPoints = function () { + return Math.ceil(this.getTimeRange() / this.binSize); + } + this.updateFromProjectConfigs = function (projectConfigs) { for (i in projectConfigs) { this.totalDuration = (this.totalDuration != 0) ? Math.min(this.totalDuration, projectConfigs[i].totalDuration) : projectConfigs[i].totalDuration; diff --git a/src/main/resources/static/scripts/schema.js b/src/main/resources/static/scripts/schema.js index 377d8c3..ae7615a 100644 --- a/src/main/resources/static/scripts/schema.js +++ b/src/main/resources/static/scripts/schema.js @@ -157,7 +157,7 @@ function Schema(schema){ } this.getMaxSegmentSize = function () { - return this.getTotalDuration() * 0.95; + return this.getTotalDuration() * CONFIG.TIMERANGE_MULTIPLIER; } return this; diff --git a/src/main/resources/static/scripts/selectors/binSelector.js b/src/main/resources/static/scripts/selectors/binSelector.js index 7ebc656..ae23d1c 100644 --- a/src/main/resources/static/scripts/selectors/binSelector.js +++ b/src/main/resources/static/scripts/selectors/binSelector.js @@ -104,14 +104,14 @@ function BinSelector(id, title, fromLabel, fromValue, toValue, step, initValue, this.slider.slider("option", "step", this.step); } - this.onSlideChanged = !isNull(onSlideChanged) ? onSlideChanged : function( event, ui ) { - var sliderId = event.target.id.replace("slider-", ""); - var tab = getTabForSelector(sliderId); - if (tab != null){ - tab.toolPanel.binSelector.setValues( ui.values[ 0 ], "slider"); - tab.toolPanel.binSelector.onSelectorValuesChanged(); - } - }; + this.onSlideChanged = !isNull(onSlideChanged) ? onSlideChanged : function( event, ui ) { + var sliderId = event.target.id.replace("slider-", ""); + var tab = getTabForSelector(sliderId); + if (tab != null){ + tab.toolPanel.binSelector.setValues( ui.values[ 0 ], "slider"); + tab.toolPanel.binSelector.onSelectorValuesChanged(); + } + }; this.createSlider = function () { this.slider.slider({ diff --git a/src/main/resources/static/scripts/selectors/sliderSelector.js b/src/main/resources/static/scripts/selectors/sliderSelector.js index a41fdd9..e81587f 100644 --- a/src/main/resources/static/scripts/selectors/sliderSelector.js +++ b/src/main/resources/static/scripts/selectors/sliderSelector.js @@ -51,7 +51,7 @@ function sliderSelector(id, title, filterData, fromLabel, toLabel, fromValue, to this.inputChanged = function ( event ) { currentObj.setValues( getInputFloatValue(currentObj.fromInput, currentObj.fromValue), getInputFloatValue(currentObj.toInput, currentObj.toValue) ); - currentObj.onSelectorValuesChanged(); + currentObj.onSelectorValuesChanged(currentObj); }; this.fromInput.on('change', this.inputChanged); this.toInput.on('change', this.inputChanged); @@ -60,8 +60,9 @@ function sliderSelector(id, title, filterData, fromLabel, toLabel, fromValue, to this.switchBox.click( function ( event ) { var switchId = event.target.id.replace("switch_", ""); var sliderSelectors_array = getTabForSelector(switchId).toolPanel.selectors_array; - sliderSelectors_array[switchId].setEnabled (!sliderSelectors_array[switchId].enabled); - sliderSelectors_array[switchId].onSelectorValuesChanged(); + var slider = sliderSelectors_array[switchId]; + slider.setEnabled (!slider.enabled); + slider.onSelectorValuesChanged(slider); }); if (!this.disableable) { @@ -75,7 +76,7 @@ function sliderSelector(id, title, filterData, fromLabel, toLabel, fromValue, to var sliderSelectors_array = tab.toolPanel.selectors_array; var sliderWdg = sliderSelectors_array[sliderId]; sliderWdg.setValues( ui.values[ 0 ], ui.values[ 1 ], "slider"); - sliderWdg.onSelectorValuesChanged(); + sliderWdg.onSelectorValuesChanged(sliderWdg); } }; @@ -130,13 +131,6 @@ function sliderSelector(id, title, filterData, fromLabel, toLabel, fromValue, to this.fromValue = from; this.toValue = to; - if (this.filterData.column == "TIME") { - //Fixes values to binSize steps - var tabPanel = getTabForSelector(this.id); - this.step = parseFloat(tabPanel.projectConfig.binSize); - this.fixed_step = this.step; - } - this.snapValuesToStep(); this.snapValuesToPrecision(); @@ -147,17 +141,14 @@ function sliderSelector(id, title, filterData, fromLabel, toLabel, fromValue, to this.slider.slider('values', 1, this.toValue); } this.slider.slider("option", "step", this.step); - - if (this.filterData.column == "TIME") { - //Notifies that time range has changed - tabPanel.onTimeRangeChanged(Math.max ((this.toValue - this.fromValue) * 0.95, this.step)); - } } - this.setFixedStep = function (fixed_step) { + this.setFixedStep = function (fixed_step, updateValues) { this.step = fixed_step; this.fixed_step = fixed_step; - this.setValues( this.fromValue, this.toValue ); + if (isNull(updateValues) || updateValues){ + this.setValues( this.fromValue, this.toValue ); + } } this.snapValuesToStep = function () { @@ -202,7 +193,7 @@ function sliderSelector(id, title, filterData, fromLabel, toLabel, fromValue, to this.setValues( filter.from, filter.to ); this.setEnabled (true); - this.onSelectorValuesChanged(); + this.onSelectorValuesChanged(this); } } diff --git a/src/main/resources/static/scripts/tabPanels/wfTabpanel.js b/src/main/resources/static/scripts/tabPanels/wfTabpanel.js index 6964663..4a945f2 100644 --- a/src/main/resources/static/scripts/tabPanels/wfTabpanel.js +++ b/src/main/resources/static/scripts/tabPanels/wfTabpanel.js @@ -501,13 +501,8 @@ function WfTabPanel (id, classSelector, navItemClass, service, navBarList, panel } this.onTimeRangeChanged = function (timeRange) { - this.updateTimeRange(timeRange); - this.toolPanel.onTimeRangeChanged(timeRange); - } - - this.updateTimeRange = function (timeRange) { - this.projectConfig.maxSegmentSize = timeRange * 0.95; //Math.min (timeRange * 0.95, currentObj.projectConfig.maxSegmentSize); - this.projectConfig.avgSegmentSize = this.projectConfig.maxSegmentSize / CONFIG.DEFAULT_SEGMENT_DIVIDER; + this.projectConfig.setTimeRange(timeRange); + this.toolPanel.onNumPointsChanged(this.projectConfig.getNumPoints()); } this.getReplaceColumn = function () { diff --git a/src/main/resources/static/scripts/toolpanel.js b/src/main/resources/static/scripts/toolpanel.js index c15d1b4..912a39e 100644 --- a/src/main/resources/static/scripts/toolpanel.js +++ b/src/main/resources/static/scripts/toolpanel.js @@ -155,15 +155,43 @@ function ToolPanel (id, this.sngOrMultiFileSelector.remove(); } - this.onTimeRangeChanged = function (timeRange) { - /*if (CONFIG.AUTO_BINSIZE && !isNull(this.binSelector)){ + /*this.onTimeRangeChanged = function (timeRange) { + if (CONFIG.AUTO_BINSIZE && !isNull(this.binSelector)){ var tab = getTabForSelector(this.id); if (!isNull(tab)){ var minValue = Math.max(timeRange / CONFIG.MAX_PLOT_POINTS, tab.projectConfig.minBinSize); var maxValue = Math.max(Math.min(timeRange / CONFIG.MIN_PLOT_POINTS, tab.projectConfig.maxBinSize), minValue * CONFIG.MIN_PLOT_POINTS); this.binSelector.setMinMaxValues(minValue, maxValue); } - }*/ + } + }*/ + + this.onBinSizeChanged = function () { + currentObj.onSelectorValuesChanged(); + var tab = getTabForSelector(currentObj.id); + if (!isNull(tab)){ + if (!isNull(currentObj.timeSelector)) { + currentObj.timeSelector.setFixedStep(tab.projectConfig.binSize, false); + } + currentObj.onNumPointsChanged(tab.projectConfig.getNumPoints()); + } + } + + this.onNumPointsChanged = function (numPoints) { + if (numPoints > CONFIG.MAX_PLOT_POINTS) { + this.showWarn("You are about to plot " + numPoints + " points. Performance will be degraded."); + } else { + this.showWarn(""); + } + } + + this.showWarn = function (msg) { + this.$html.find(".selectorsContainer").find(".btnWarn").remove(); + if (!isNull(msg) && msg != ""){ + this.$html.find(".selectorsContainer").prepend($('
' + + ' ' + msg + + '
')); + } } this.onDatasetSchemaChanged = function ( projectConfig ) { @@ -213,7 +241,7 @@ function ToolPanel (id, binSelectorConfig.maxBinSize, binSelectorConfig.step, binSelectorConfig.binSize, - this.onSelectorValuesChanged, + this.onBinSizeChanged, null, CONFIG.MAX_TIME_RESOLUTION_DECIMALS); this.$html.find(".selectorsContainer").append(this.binSelector.$html); @@ -253,19 +281,32 @@ function ToolPanel (id, filterData, "From", "To", column.min_value, column.max_value, - this.onSelectorValuesChanged, + (columnName != "TIME") ? + this.onSelectorValuesChanged : + function (selector) { + //Notifies that time range has changed + var tabPanel = getTabForSelector(selector.id); + if (!isNull(tabPanel)){ + tabPanel.onTimeRangeChanged(Math.max ((selector.toValue - selector.fromValue) * 0.95, selector.step)); + } + }, this.selectors_array, null, CONFIG.MAX_TIME_RESOLUTION_DECIMALS); this.$html.find(".selectorsContainer").append(selector.$html); - if ((columnName == "TIME") - && (!CONFIG.AUTO_BINSIZE || projectConfig.schema.isLightCurveFile()) - && projectConfig.isMaxTimeRangeRatioFixed()) { + if (columnName == "TIME"){ + + //Stores this selector + this.timeSelector = selector; - //If full events were cropped to CONFIG.MAX_PLOT_POINTS - //selector.setMaxRange(projectConfig.getMaxTimeRange()); - selector.setValues( selector.initFromValue, selector.initFromValue + projectConfig.getMaxTimeRange() ); - selector.setEnabled (true); + if ((!CONFIG.AUTO_BINSIZE || projectConfig.schema.isLightCurveFile()) + && projectConfig.isMaxTimeRangeRatioFixed()) { + + //If full events were cropped to CONFIG.MAX_PLOT_POINTS + //selector.setMaxRange(projectConfig.getMaxTimeRange()); + selector.setValues( selector.initFromValue, selector.initFromValue + projectConfig.getMaxTimeRange() ); + selector.setEnabled (true); + } } if (tableName == "EVENTS" && columnName == "PHA") { diff --git a/src/main/resources/static/styles/master_page.css b/src/main/resources/static/styles/master_page.css index 9fc0849..ba3103f 100644 --- a/src/main/resources/static/styles/master_page.css +++ b/src/main/resources/static/styles/master_page.css @@ -344,6 +344,10 @@ ul#right-navbar li { margin-bottom: -2px; } +.selectorsContainer .btnWarn { + margin-top: 24px; +} + .bigWarnBtn { width: 73%; } From b4d08aff7b92d59a6736c2044f0288969d2d31b8 Mon Sep 17 00:00:00 2001 From: Ricardo Valles Blanco Date: Mon, 18 Sep 2017 21:02:05 +0200 Subject: [PATCH 08/10] Fix RATE filter bug on light curves with binSize <> 1 --- .../static/scripts/selectors/sliderSelector.js | 5 +++-- src/main/resources/static/scripts/toolpanel.js | 10 +++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/main/resources/static/scripts/selectors/sliderSelector.js b/src/main/resources/static/scripts/selectors/sliderSelector.js index e81587f..931aac8 100644 --- a/src/main/resources/static/scripts/selectors/sliderSelector.js +++ b/src/main/resources/static/scripts/selectors/sliderSelector.js @@ -24,6 +24,7 @@ function sliderSelector(id, title, filterData, fromLabel, toLabel, fromValue, to this.onSelectorValuesChanged = onSelectorValuesChangedFn; this.enabled = false; this.disableable = isNull(this.filterData.source); + this.multiplier = 1.0; if (!isNull(selectors_array)){ selectors_array[this.id] = this; @@ -165,8 +166,8 @@ function sliderSelector(id, title, filterData, fromLabel, toLabel, fromValue, to this.getFilter = function () { if (this.enabled) { - this.filterData.from = this.fromValue; - this.filterData.to = this.toValue; + this.filterData.from = this.fromValue * this.multiplier; + this.filterData.to = this.toValue * this.multiplier; return this.filterData; } else { return null; diff --git a/src/main/resources/static/scripts/toolpanel.js b/src/main/resources/static/scripts/toolpanel.js index 912a39e..8885db5 100644 --- a/src/main/resources/static/scripts/toolpanel.js +++ b/src/main/resources/static/scripts/toolpanel.js @@ -270,17 +270,24 @@ function ToolPanel (id, var column = table[columnName]; if (!excludedFilters.includes(columnName) && column.min_value < column.max_value) { + var multiplier = 1.0; var filterData = { table:tableName, column:columnName }; var columnTitle = columnName + ":"; if (columnName == "TIME") { columnTitle = "TIME (" + projectConfig.timeUnit + "):"; + } else if ((columnName == "RATE") && projectConfig.schema.isLightCurveFile()){ + //This multiplier its only intended to calculate CountRate from counts when BinSize != 1 + //The RATE values that comes from schema means counts, but filters and LCs shows countrate + //so a multiplication by binSize is requiered for calculating the rate. + multiplier = projectConfig.binSize; } var selector = new sliderSelector(this.id + "_" + columnName, columnTitle, filterData, "From", "To", - column.min_value, column.max_value, + Math.floor(column.min_value / multiplier), + Math.ceil(column.max_value / multiplier), (columnName != "TIME") ? this.onSelectorValuesChanged : function (selector) { @@ -292,6 +299,7 @@ function ToolPanel (id, }, this.selectors_array, null, CONFIG.MAX_TIME_RESOLUTION_DECIMALS); + selector.multiplier = multiplier; this.$html.find(".selectorsContainer").append(selector.$html); if (columnName == "TIME"){ From 06cbe3c9bd9ed9bb090696c58e33658709ebc148 Mon Sep 17 00:00:00 2001 From: Ricardo Valles Blanco Date: Mon, 18 Sep 2017 21:53:26 +0200 Subject: [PATCH 09/10] Changed Dave_work folder for .dave --- setup/config/deply_darwin_config.js | 2 +- setup/config/deply_linux_config.js | 2 +- src/main/resources/bash/activate_and_launch.bash | 2 +- src/main/resources/bash/create_env.bash | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/setup/config/deply_darwin_config.js b/setup/config/deply_darwin_config.js index f28125f..ba778d6 100644 --- a/setup/config/deply_darwin_config.js +++ b/setup/config/deply_darwin_config.js @@ -9,6 +9,6 @@ module.exports = { url : 'http://localhost:5000' }, logDebugMode : 'true', - logsPath : '$HOME/Dave_work/flaskserver.log', + logsPath : '$HOME/.dave/flaskserver.log', splash_path : '/../../../dave/resources/templates/splash_page.html' }; diff --git a/setup/config/deply_linux_config.js b/setup/config/deply_linux_config.js index ba81b62..db7e145 100644 --- a/setup/config/deply_linux_config.js +++ b/setup/config/deply_linux_config.js @@ -9,6 +9,6 @@ module.exports = { url : 'http://localhost:5000' }, logDebugMode : 'true', - logsPath : '$HOME/Dave_work/flaskserver.log', + logsPath : '$HOME/.dave/flaskserver.log', splash_path : '/../resources/templates/splash_page.html' }; diff --git a/src/main/resources/bash/activate_and_launch.bash b/src/main/resources/bash/activate_and_launch.bash index 84ad6a9..ae80208 100755 --- a/src/main/resources/bash/activate_and_launch.bash +++ b/src/main/resources/bash/activate_and_launch.bash @@ -21,7 +21,7 @@ cd $RES_DIR RES_DIR=$(pwd) cd - -ENVDIR=$HOME/Dave_work +ENVDIR=$HOME/.dave echo "Python Environment folder: $ENVDIR" #Check DAVE environment version diff --git a/src/main/resources/bash/create_env.bash b/src/main/resources/bash/create_env.bash index 591c96b..098cf3e 100644 --- a/src/main/resources/bash/create_env.bash +++ b/src/main/resources/bash/create_env.bash @@ -43,7 +43,7 @@ fi # install in directory work in the top-level dir in the project DIR=$_SCRIPT_FOLDER/../.. -WORKDIR=$HOME/Dave_work +WORKDIR=$HOME/.dave if [ ! -e $WORKDIR ]; then echo "Creating Python Environment folder: $WORKDIR" From 239fe91e86e4e14653c793a0ab5a083edba2285e Mon Sep 17 00:00:00 2001 From: Ricardo Valles Blanco Date: Mon, 18 Sep 2017 22:12:10 +0200 Subject: [PATCH 10/10] Change plot binSize selector text --- src/main/resources/static/scripts/plots/plotWithSettings.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/static/scripts/plots/plotWithSettings.js b/src/main/resources/static/scripts/plots/plotWithSettings.js index f684252..7d4b3c4 100644 --- a/src/main/resources/static/scripts/plots/plotWithSettings.js +++ b/src/main/resources/static/scripts/plots/plotWithSettings.js @@ -219,7 +219,7 @@ function PlotWithSettings(id, plotConfig, getDataFromServerFn, onFiltersChangedF //Adds the custom binSize switch var $binSelectorCheckBox = $('
' + - 'Use general bin size' + + 'Use bin size on filter tab' + '
' + '' + '
' +