Skip to content

Commit

Permalink
Merge pull request #69 from StingraySoftware/Sprint_Week_36
Browse files Browse the repository at this point in the history
Sprint week 36
  • Loading branch information
pbalm authored Dec 3, 2017
2 parents 8fbf293 + 9ece7a1 commit eeb0264
Show file tree
Hide file tree
Showing 29 changed files with 1,106 additions and 194 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ You will see that there's plenty left to do!

NOTE: Mac OSX dependencies
* At least Homebrew installed (http://brew.sh/) or MacPorts installed (https://www.macports.org)
* Administrator rights are required for using MacPorts, please run Dave using: sudo DAVEApp.app/Contents/MacOS/DAVEApp
* If MacPorts will be used, you have two available options:
* 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`.
* 2 - Launch DAVE as root running this command on the terminal: `sudo DAVEApp.app/Contents/MacOS/DAVEApp`


## Contribute
Expand Down
21 changes: 13 additions & 8 deletions setup/setup.bash
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
# Source this script to set up the environment for developing DAVE.
# - Download miniconda and install packages and virtual env
# - Download node and install packages
# - Install Python dependencies
# - Install Stingray and Astropy Helpers
# - Install Hendrics
# - Install LibMagic
# - Install node modules

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

sudo installer -pkg $NODE_TAR -target /
installer -pkg $NODE_TAR -target /

else
# Unknown.
Expand Down Expand Up @@ -169,8 +174,8 @@ source activate dave
STINGRAY_FOLDER=$DIR/stingray
STINGRAY_URL=https://github.com/StingraySoftware/stingray.git
# Sets the specific commit to checkout:
# Oct 22th, 2017 -> https://github.com/StingraySoftware/stingray/commit/b64aceb3197062ffd65bfd735ebff190a34e1066
STINGRAY_COMMIT_HASH=b64aceb3197062ffd65bfd735ebff190a34e1066
# Nov 7th, 2017 -> https://github.com/StingraySoftware/stingray/commit/0870c2051dadd9fd921fe286132971eb31b6a199
STINGRAY_COMMIT_HASH=0870c2051dadd9fd921fe286132971eb31b6a199
LINUX_COMPILATION=lib.linux-x86_64-3.5
DARWIN_COMPILATION=lib.macosx-10.5-x86_64-3.5

Expand Down Expand Up @@ -220,12 +225,12 @@ if [ ! -e $STINGRAY_FOLDER ]; then
# Mac OSX

#Build stingray
sudo python setup.py install
python setup.py install

cd $STINGRAY_FOLDER/astropy_helpers

#Build astropy_helpers
sudo python setup.py install
python setup.py install

cd $DIR/..

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

if [ ! -e $HENDRICS_FOLDER ]; then

Expand Down Expand Up @@ -275,7 +280,7 @@ if [ ! -e $HENDRICS_FOLDER ]; then
# Mac OSX

#Build HENDRICS
sudo python setup.py install
python setup.py install

cd $DIR/..

Expand Down
25 changes: 15 additions & 10 deletions src/main/js/electron/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@ var rq = require('request-promise');
var Config = require('config-js');
var Menu = require("menu");
var request = require('request');
var fs = require('fs');

let mainWindow,
windowParams = {
width:1200,
height: 700,
minHeight: 300,
minWidth: 768,
icon: "resources/resources/static/img/icon.png"
};
var retryInterval = 0.5 * 1000;
Expand Down Expand Up @@ -85,7 +88,7 @@ function launchPythonServer(config, callback) {
} else if (config.pythonEnabled) {
launchProcess ("python", [config.pythonPath, '/tmp', '..', port, 'PY_ENV'], "Python");
} else if (config.envEnabled) {
launchProcess ("/bin/bash", [config.envScriptPath], "Env&Python");
launchProcess ("/bin/bash", [config.envScriptPath], "E&P");
}

if (callback != null) {
Expand Down Expand Up @@ -261,15 +264,17 @@ function connectionLost (){
}

function getTailFromLogFile (logFilePath) {
log('Getting log info from: ' + logFilePath, "Warn");
var tailProc = cp.spawn("tail", [ "-10", logFilePath ]);
var stdout = "";
tailProc.stdout.on('data', (data) => {
stdout += data;
});
tailProc.on('close', (code) => {
log("LOGFILE: " + stdout);
});
if (fs.existsSync(logFilePath)) {
log('Getting log info from: ' + logFilePath, "Warn");
var tailProc = cp.spawn("tail", [ "-10", logFilePath ]);
var stdout = "";
tailProc.stdout.on('data', (data) => {
stdout += data;
});
tailProc.on('close', (code) => {
log("LOGFILE: " + stdout);
});
}
}

function escapeSpecialChars (text) {
Expand Down
19 changes: 17 additions & 2 deletions src/main/python/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def append_file_to_dataset():

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


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


@app.route('/get_rms_vs_countrate', methods=['POST'])
def get_rms_vs_countrate():
return DaveEndpoint.get_rms_vs_countrate(request.json['filename'],
request.json['bck_filename'], request.json['gti_filename'], UPLOADS_TARGET,
request.json['filters'], request.json['axis'], float(request.json['dt']),
int(request.json['n_bands']), float(request.json['df']),
request.json['freq_range'], request.json['energy_range'])


@app.route('/get_plot_data_from_models', methods=['POST'])
def get_plot_data_from_models():
return DaveEndpoint.get_plot_data_from_models(request.json['models'], request.json['x_values'])
Expand Down Expand Up @@ -284,10 +293,16 @@ def get_pulse_search():

@app.route('/get_phaseogram', methods=['POST'])
def get_phaseogram():

binary_params= None
if "binary_params" in request.json:
binary_params = request.json['binary_params']

return DaveEndpoint.get_phaseogram(request.json['filename'],
request.json['bck_filename'], request.json['gti_filename'], UPLOADS_TARGET,
request.json['filters'], request.json['axis'], float(request.json['dt']),
float(request.json['f']), int(request.json['nph']), int(request.json['nt']))
float(request.json['f']), int(request.json['nph']), int(request.json['nt']),
float(request.json['fdot']), float(request.json['fddot']), binary_params)


# Receives a message from client and send it to all subscribers
Expand Down
50 changes: 46 additions & 4 deletions src/main/python/utils/dave_endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,9 @@ def append_file_to_dataset(filename, nextfile, target):
# Creates a new column E with Enery data on dataset
# @param: filename: filename or dataset cache key
# @param: rmf_filename: rmf file to apply
# @param: column: column to use for the conversion: PHA, or PI for NuSTAR
#
def apply_rmf_file_to_dataset(filename, rmf_filename, target):
def apply_rmf_file_to_dataset(filename, rmf_filename, column, target):
destination = get_destination(filename, target)
if not destination:
return common_error("Invalid file or cache key")
Expand All @@ -134,7 +135,7 @@ def apply_rmf_file_to_dataset(filename, rmf_filename, target):
if not FileUtils.is_valid_file(rmf_destination):
return common_error("Invalid RMF file")

result = DaveEngine.apply_rmf_file_to_dataset(destination, rmf_destination)
result = DaveEngine.apply_rmf_file_to_dataset(destination, rmf_destination, column)
return json.dumps(result)


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


def get_rms_vs_countrate(src_filename, bck_filename, gti_filename, target,
filters, axis, dt, nsegm, df, freq_range, energy_range):
src_destination = get_destination(src_filename, target)
if not src_destination:
return common_error("Invalid file or cache key for source data")

bck_destination = ""
if bck_filename:
bck_destination = get_destination(bck_filename, target)
if not bck_destination:
return common_error("Invalid file or cache key for backgrund data")

gti_destination = ""
if gti_filename:
gti_destination = get_destination(gti_filename, target)
if not gti_destination:
return common_error("Invalid file or cache key for gti data")

logging.debug("get_rms_vs_countrate src: %s" % src_filename)
logging.debug("get_rms_vs_countrate bck: %s" % bck_filename)
logging.debug("get_rms_vs_countrate gti: %s" % gti_filename)
logging.debug("get_rms_vs_countrate: filters %s" % filters)
logging.debug("get_rms_vs_countrate: axis %s" % axis)
logging.debug("get_rms_vs_countrate: dt %s" % dt)
logging.debug("get_rms_vs_countrate: nsegm %f" % nsegm)
logging.debug("get_rms_vs_countrate: df %s" % df)
logging.debug("get_rms_vs_countrate: freq_range %s" % freq_range)
logging.debug("get_rms_vs_countrate: energy_range %s" % energy_range)

data = DaveEngine.get_rms_vs_countrate(src_destination, bck_destination, gti_destination,
filters, axis, dt, nsegm, df, freq_range, energy_range)

logging.debug("get_rms_vs_countrate: Finish!")

return json.dumps(data, cls=NPEncoder)


def get_plot_data_from_models(models, x_values):

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


def get_phaseogram(src_filename, bck_filename, gti_filename, target,
filters, axis, dt, f, nph, nt):
filters, axis, dt, f, nph, nt, fdot=0, fddot=0,
binary_parameters=None):

src_destination = get_destination(src_filename, target)
if not src_destination:
Expand All @@ -853,9 +892,12 @@ def get_phaseogram(src_filename, bck_filename, gti_filename, target,
logging.debug("get_phaseogram: f %s" % f)
logging.debug("get_phaseogram: nph %s" % nph)
logging.debug("get_phaseogram: nt %s" % nt)
logging.debug("get_phaseogram: fdot %s" % fdot)
logging.debug("get_phaseogram: fddot %s" % fddot)
logging.debug("get_phaseogram: binary_parameters %s" % binary_parameters)

data = DaveEngine.get_phaseogram(src_destination, bck_destination, gti_destination,
filters, axis, dt, f, nph, nt)
filters, axis, dt, f, nph, nt, fdot, fddot, binary_parameters)

logging.debug("get_phaseogram: Finish!")

Expand Down
Loading

0 comments on commit eeb0264

Please sign in to comment.