-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathjson_calculate.php
More file actions
executable file
·53 lines (40 loc) · 1.69 KB
/
json_calculate.php
File metadata and controls
executable file
·53 lines (40 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
ini_set('display_errors', 'On');
$params = array();
$params["spectrograph"] = $_REQUEST["instrument"];
$params["outputType"] = $_REQUEST["outputType"];
//Check for the output type mode and get the "crtical value"
if ($params["outputType"] == "1"){
$params["depth"] = floatval($_REQUEST["sn"]);
$params["calcType"] = 'Time';
} else {
$params["depth"] = floatval($_REQUEST["time"]);
$params["calcType"] = 'SNR';
};
//Grab the other parameters we need
$params["grating"] = $_REQUEST["grating_selector"];
$params["order"] = intval($_REQUEST["order"]);
$params["cenwave"] = floatval($_REQUEST["cenwave"]);
$params["filter"] = $_REQUEST["filters"];
$params["binning_spatial"] = intval($_REQUEST["spatialBinning"]);
$params["binning_spectral"] = intval($_REQUEST["spectralBinning"]);
$params["slit_width"] = floatval($_REQUEST["slitplates"]);
$params["seeing"] = floatval($_REQUEST["seeing"]);
$params["specmag"] = floatval($_REQUEST["ABmag"]);
$params["lunar_phase"] = floatval($_REQUEST["lunarphase"]);
$params["airmass"] = floatval($_REQUEST["airmass"]);
$errors = array(); // To Store Errors
$form_data = array(); // Pass back to index
//Execute the python script with JSON data
$result = shell_exec("python python/json_exptime.py " . escapeshellarg(json_encode($params)));
//Decode the result
$form_data = json_decode($result, true);
$form_data['command'] = "python python/json_exptime.py " . escapeshellarg(json_encode($params));
if (!empty($errors)) { // If there were any errors
$form_data['success'] = false;
$form_data['errors'] = $errors;
} else { // If no, process the form
$form_data['success'] = true;
}
echo json_encode($form_data);
?>