Skip to content

Commit eeb0264

Browse files
authored
Merge pull request #69 from StingraySoftware/Sprint_Week_36
Sprint week 36
2 parents 8fbf293 + 9ece7a1 commit eeb0264

29 files changed

Lines changed: 1106 additions & 194 deletions

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ You will see that there's plenty left to do!
2020

2121
NOTE: Mac OSX dependencies
2222
* At least Homebrew installed (http://brew.sh/) or MacPorts installed (https://www.macports.org)
23-
* Administrator rights are required for using MacPorts, please run Dave using: sudo DAVEApp.app/Contents/MacOS/DAVEApp
23+
* If MacPorts will be used, you have two available options:
24+
* 1 - Install LibMagic by yourself running this MacPorts command `sudo /opt/local/bin/port install file` on the terminal and then launch DAVE running `DAVEApp.app/Contents/MacOS/DAVEApp`.
25+
* 2 - Launch DAVE as root running this command on the terminal: `sudo DAVEApp.app/Contents/MacOS/DAVEApp`
2426

2527

2628
## Contribute

setup/setup.bash

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
# Source this script to set up the environment for developing DAVE.
44
# - Download miniconda and install packages and virtual env
55
# - Download node and install packages
6+
# - Install Python dependencies
7+
# - Install Stingray and Astropy Helpers
8+
# - Install Hendrics
9+
# - Install LibMagic
10+
# - Install node modules
611

712
# First check if the script is being sourced...
813
if [[ "${BASH_SOURCE[0]}" == "${0}" ]] ; then
@@ -114,7 +119,7 @@ NODE_FILENAME="node-v$NODE_VERSION"
114119
fi
115120
fi
116121

117-
sudo installer -pkg $NODE_TAR -target /
122+
installer -pkg $NODE_TAR -target /
118123

119124
else
120125
# Unknown.
@@ -169,8 +174,8 @@ source activate dave
169174
STINGRAY_FOLDER=$DIR/stingray
170175
STINGRAY_URL=https://github.com/StingraySoftware/stingray.git
171176
# Sets the specific commit to checkout:
172-
# Oct 22th, 2017 -> https://github.com/StingraySoftware/stingray/commit/b64aceb3197062ffd65bfd735ebff190a34e1066
173-
STINGRAY_COMMIT_HASH=b64aceb3197062ffd65bfd735ebff190a34e1066
177+
# Nov 7th, 2017 -> https://github.com/StingraySoftware/stingray/commit/0870c2051dadd9fd921fe286132971eb31b6a199
178+
STINGRAY_COMMIT_HASH=0870c2051dadd9fd921fe286132971eb31b6a199
174179
LINUX_COMPILATION=lib.linux-x86_64-3.5
175180
DARWIN_COMPILATION=lib.macosx-10.5-x86_64-3.5
176181

@@ -220,12 +225,12 @@ if [ ! -e $STINGRAY_FOLDER ]; then
220225
# Mac OSX
221226

222227
#Build stingray
223-
sudo python setup.py install
228+
python setup.py install
224229

225230
cd $STINGRAY_FOLDER/astropy_helpers
226231

227232
#Build astropy_helpers
228-
sudo python setup.py install
233+
python setup.py install
229234

230235
cd $DIR/..
231236

@@ -239,8 +244,8 @@ fi
239244
HENDRICS_FOLDER=$DIR/hendrics
240245
HENDRICS_URL=https://github.com/StingraySoftware/HENDRICS.git
241246
# Sets the specific commit to checkout:
242-
# Oct 20th, 2017 -> https://github.com/StingraySoftware/HENDRICS/commit/9c4f95ec30837bc0bc8077b369e4957bcccefb16
243-
HENDRICS_COMMIT_HASH=9c4f95ec30837bc0bc8077b369e4957bcccefb16
247+
# Oct 27th, 2017 -> https://github.com/StingraySoftware/HENDRICS/commit/53ebffd826583027acc7ccad565029babd08d24d
248+
HENDRICS_COMMIT_HASH=53ebffd826583027acc7ccad565029babd08d24d
244249

245250
if [ ! -e $HENDRICS_FOLDER ]; then
246251

@@ -275,7 +280,7 @@ if [ ! -e $HENDRICS_FOLDER ]; then
275280
# Mac OSX
276281

277282
#Build HENDRICS
278-
sudo python setup.py install
283+
python setup.py install
279284

280285
cd $DIR/..
281286

src/main/js/electron/main.js

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,14 @@ var rq = require('request-promise');
88
var Config = require('config-js');
99
var Menu = require("menu");
1010
var request = require('request');
11+
var fs = require('fs');
1112

1213
let mainWindow,
1314
windowParams = {
1415
width:1200,
1516
height: 700,
17+
minHeight: 300,
18+
minWidth: 768,
1619
icon: "resources/resources/static/img/icon.png"
1720
};
1821
var retryInterval = 0.5 * 1000;
@@ -85,7 +88,7 @@ function launchPythonServer(config, callback) {
8588
} else if (config.pythonEnabled) {
8689
launchProcess ("python", [config.pythonPath, '/tmp', '..', port, 'PY_ENV'], "Python");
8790
} else if (config.envEnabled) {
88-
launchProcess ("/bin/bash", [config.envScriptPath], "Env&Python");
91+
launchProcess ("/bin/bash", [config.envScriptPath], "E&P");
8992
}
9093

9194
if (callback != null) {
@@ -261,15 +264,17 @@ function connectionLost (){
261264
}
262265

263266
function getTailFromLogFile (logFilePath) {
264-
log('Getting log info from: ' + logFilePath, "Warn");
265-
var tailProc = cp.spawn("tail", [ "-10", logFilePath ]);
266-
var stdout = "";
267-
tailProc.stdout.on('data', (data) => {
268-
stdout += data;
269-
});
270-
tailProc.on('close', (code) => {
271-
log("LOGFILE: " + stdout);
272-
});
267+
if (fs.existsSync(logFilePath)) {
268+
log('Getting log info from: ' + logFilePath, "Warn");
269+
var tailProc = cp.spawn("tail", [ "-10", logFilePath ]);
270+
var stdout = "";
271+
tailProc.stdout.on('data', (data) => {
272+
stdout += data;
273+
});
274+
tailProc.on('close', (code) => {
275+
log("LOGFILE: " + stdout);
276+
});
277+
}
273278
}
274279

275280
function escapeSpecialChars (text) {

src/main/python/server.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def append_file_to_dataset():
101101

102102
@app.route('/apply_rmf_file_to_dataset', methods=['GET'])
103103
def apply_rmf_file_to_dataset():
104-
return DaveEndpoint.apply_rmf_file_to_dataset(request.args['filename'], request.args['rmf_filename'], UPLOADS_TARGET)
104+
return DaveEndpoint.apply_rmf_file_to_dataset(request.args['filename'], request.args['rmf_filename'], request.args['column'], UPLOADS_TARGET)
105105

106106

107107
@app.route('/get_plot_data', methods=['POST'])
@@ -202,6 +202,15 @@ def get_rms_spectrum():
202202
request.json['freq_range'], request.json['energy_range'], int(request.json['n_bands']))
203203

204204

205+
@app.route('/get_rms_vs_countrate', methods=['POST'])
206+
def get_rms_vs_countrate():
207+
return DaveEndpoint.get_rms_vs_countrate(request.json['filename'],
208+
request.json['bck_filename'], request.json['gti_filename'], UPLOADS_TARGET,
209+
request.json['filters'], request.json['axis'], float(request.json['dt']),
210+
int(request.json['n_bands']), float(request.json['df']),
211+
request.json['freq_range'], request.json['energy_range'])
212+
213+
205214
@app.route('/get_plot_data_from_models', methods=['POST'])
206215
def get_plot_data_from_models():
207216
return DaveEndpoint.get_plot_data_from_models(request.json['models'], request.json['x_values'])
@@ -284,10 +293,16 @@ def get_pulse_search():
284293

285294
@app.route('/get_phaseogram', methods=['POST'])
286295
def get_phaseogram():
296+
297+
binary_params= None
298+
if "binary_params" in request.json:
299+
binary_params = request.json['binary_params']
300+
287301
return DaveEndpoint.get_phaseogram(request.json['filename'],
288302
request.json['bck_filename'], request.json['gti_filename'], UPLOADS_TARGET,
289303
request.json['filters'], request.json['axis'], float(request.json['dt']),
290-
float(request.json['f']), int(request.json['nph']), int(request.json['nt']))
304+
float(request.json['f']), int(request.json['nph']), int(request.json['nt']),
305+
float(request.json['fdot']), float(request.json['fddot']), binary_params)
291306

292307

293308
# Receives a message from client and send it to all subscribers

src/main/python/utils/dave_endpoint.py

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,9 @@ def append_file_to_dataset(filename, nextfile, target):
121121
# Creates a new column E with Enery data on dataset
122122
# @param: filename: filename or dataset cache key
123123
# @param: rmf_filename: rmf file to apply
124+
# @param: column: column to use for the conversion: PHA, or PI for NuSTAR
124125
#
125-
def apply_rmf_file_to_dataset(filename, rmf_filename, target):
126+
def apply_rmf_file_to_dataset(filename, rmf_filename, column, target):
126127
destination = get_destination(filename, target)
127128
if not destination:
128129
return common_error("Invalid file or cache key")
@@ -134,7 +135,7 @@ def apply_rmf_file_to_dataset(filename, rmf_filename, target):
134135
if not FileUtils.is_valid_file(rmf_destination):
135136
return common_error("Invalid RMF file")
136137

137-
result = DaveEngine.apply_rmf_file_to_dataset(destination, rmf_destination)
138+
result = DaveEngine.apply_rmf_file_to_dataset(destination, rmf_destination, column)
138139
return json.dumps(result)
139140

140141

@@ -572,6 +573,43 @@ def get_rms_spectrum(src_filename, bck_filename, gti_filename, target,
572573
return json.dumps(data, cls=NPEncoder)
573574

574575

576+
def get_rms_vs_countrate(src_filename, bck_filename, gti_filename, target,
577+
filters, axis, dt, nsegm, df, freq_range, energy_range):
578+
src_destination = get_destination(src_filename, target)
579+
if not src_destination:
580+
return common_error("Invalid file or cache key for source data")
581+
582+
bck_destination = ""
583+
if bck_filename:
584+
bck_destination = get_destination(bck_filename, target)
585+
if not bck_destination:
586+
return common_error("Invalid file or cache key for backgrund data")
587+
588+
gti_destination = ""
589+
if gti_filename:
590+
gti_destination = get_destination(gti_filename, target)
591+
if not gti_destination:
592+
return common_error("Invalid file or cache key for gti data")
593+
594+
logging.debug("get_rms_vs_countrate src: %s" % src_filename)
595+
logging.debug("get_rms_vs_countrate bck: %s" % bck_filename)
596+
logging.debug("get_rms_vs_countrate gti: %s" % gti_filename)
597+
logging.debug("get_rms_vs_countrate: filters %s" % filters)
598+
logging.debug("get_rms_vs_countrate: axis %s" % axis)
599+
logging.debug("get_rms_vs_countrate: dt %s" % dt)
600+
logging.debug("get_rms_vs_countrate: nsegm %f" % nsegm)
601+
logging.debug("get_rms_vs_countrate: df %s" % df)
602+
logging.debug("get_rms_vs_countrate: freq_range %s" % freq_range)
603+
logging.debug("get_rms_vs_countrate: energy_range %s" % energy_range)
604+
605+
data = DaveEngine.get_rms_vs_countrate(src_destination, bck_destination, gti_destination,
606+
filters, axis, dt, nsegm, df, freq_range, energy_range)
607+
608+
logging.debug("get_rms_vs_countrate: Finish!")
609+
610+
return json.dumps(data, cls=NPEncoder)
611+
612+
575613
def get_plot_data_from_models(models, x_values):
576614

577615
logging.debug("get_plot_data_from_models models: %s" % models)
@@ -826,7 +864,8 @@ def get_pulse_search(src_filename, bck_filename, gti_filename, target,
826864

827865

828866
def get_phaseogram(src_filename, bck_filename, gti_filename, target,
829-
filters, axis, dt, f, nph, nt):
867+
filters, axis, dt, f, nph, nt, fdot=0, fddot=0,
868+
binary_parameters=None):
830869

831870
src_destination = get_destination(src_filename, target)
832871
if not src_destination:
@@ -853,9 +892,12 @@ def get_phaseogram(src_filename, bck_filename, gti_filename, target,
853892
logging.debug("get_phaseogram: f %s" % f)
854893
logging.debug("get_phaseogram: nph %s" % nph)
855894
logging.debug("get_phaseogram: nt %s" % nt)
895+
logging.debug("get_phaseogram: fdot %s" % fdot)
896+
logging.debug("get_phaseogram: fddot %s" % fddot)
897+
logging.debug("get_phaseogram: binary_parameters %s" % binary_parameters)
856898

857899
data = DaveEngine.get_phaseogram(src_destination, bck_destination, gti_destination,
858-
filters, axis, dt, f, nph, nt)
900+
filters, axis, dt, f, nph, nt, fdot, fddot, binary_parameters)
859901

860902
logging.debug("get_phaseogram: Finish!")
861903

0 commit comments

Comments
 (0)