Skip to content

Commit

Permalink
Merge pull request #2 from Johaney-s/WIP
Browse files Browse the repository at this point in the history
2.0 changes
  • Loading branch information
Johaney-s authored Mar 5, 2021
2 parents f4f6905 + 985b038 commit 075b8cd
Show file tree
Hide file tree
Showing 28 changed files with 259,350 additions and 258,973 deletions.
111 changes: 111 additions & 0 deletions Manual.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
This section summarises the tool's options.

### Getting started

Head over to the Release section and get the [latest release](https://github.com/Johaney-s/StIFT/releases/latest).
To run the application, you only need to download the .jar file from there.

Ensure to have installed Java version 11 or newer. The application should run on Windows, MacOS and Linux.

## Graphical User Interface
To open the application the standard way, double click the .jar file or run `java -jar stift.jar` from the command line.

![](img/gui.gif)

### Input
Use one of the following ways of inputting the data:
- **Click the graph**, the (x, y) coordinates of cursor's position give input values.
- **Fill in the form** on the right.
- Upload **data file** via menu Data > Upload input data file.

The uncertainty is computed using 1000 estimations following the Monte Carlo simulations.
To turn off computing the uncertainty and speed the estimation up, uncheck the Compute uncertainty option.
Uncertainty that is equal to 0 is overwritten to uncertainty coming from points in evolutionary line.

To upload input data, provide a .txt file and comment out header lines with '#' symbol.
#TEMPERATURE | LUMINOSITY
--- | ---
3.944 | 1.508
4.053 | 2.383
... and more

or

#TEMPERATURE | LUMINOSITY | TEMPuncertainty | LUMuncertainty
--- | --- | --- | ---
3.944 | 1.508 | 0.014 | 0.023
4.053 | 2.383 | 0.008 | 0.027
... and more

attributes separated by space. Missing uncertainties attributes
will be set to 0.

### Grid (models)
To upload custom grid, navigate to menu Grid > Upload new grid.
Any header lines need to start with '#' sign to be parsed correctly.
Grid data need to be grouped by initial mass and sorted by evolutionary
phase. The GUI shows only a part of the grid data,
but all points are taken into account when computing.
Accepted format is a .txt file.
Use space or ',' delimiter between attributes. To obtain correct
uncertainty results, please follow the results table's header
for specification of values representation:

#Teff[lg K] | Lum[lg Lsun] | Age[dex yrs] | Rad[Rsun] | Mass[Msun] | Phase
--- | --- | --- | --- |--- |---
3.66943 | -0.72127 | 8.23306 | 10.66660 | 0.75000 | 5.00000
3.66932 | -0.72112 | 8.26683 | 10.66690 | 0.75000 | 5.00053
3.66922 | -0.72095 | 8.30172 | 10.66718 | 0.75000 | 5.00112
3.66912 | -0.72077 | 8.33767 | 10.66747 | 0.75000 | 5.00179
... and more

Default grid data is extracted from [CMD web interface](http://stev.oapd.inaf.it/cgi-bin/cmd).
Credit: PARSEC and COLIBRI tracks (Marigo et al. (2017)).

The **phase labels** in the default grid file are described [here](https://people.sissa.it/~sbressan/CAF09_V1.2S_M36_LT/readme.txt), StIFT uses these:
#Value | Phase | Description
--- | --- | ---
4 | NEAR_ZAM | This point is very near the ZAMS
5 | MS_BEG | H burning fully active
6 | POINT_B | Almost end of the H burning. Small contraction phase begins here for interm. & massive stars
7 | POINT_C | Small contraction ends here and star move toward RG
8 | RG_BASE | RG base
9 | RG_BMP1 | RGB bump in Low Mass Stars (marked also for other masses)
10 | RG_BMP2 | RGB bump end in Low Mass Stars (marked also for other masses)
11 | RG_TIP | Helium Flash or beginning of HELIUM Burning in intermediate and massive stars

### Filtering
For filtering the results in the table, use phase filter in the phase column header.
Results filtered out won't appear in the export file.

For ignoring certain phases in the interpolation, restrict them
using checkboxes. Keep in mind that the result can be estimated
in the phase that is filtered out (for example if phase 6 is ignored
but phases 5 and 7 are chosen as the nearest tracks).

### Exporting
To export results that appear in the results table, use menu Data > Export data.
In the export file, you will find estimated parameters together with their uncertainties and estimation method.

There are different estimation methods that could have been applied to estimate mean values - NONE means no method could resolve the parameters, STAR MATCH means the input point is too close to some of the points in the grid and therefore it copies this grid point's values. SIDE MATCH only implies that the point lies too close to a side of the 4-angled figure and was interpolated using only 2 of the neighbours. FULL ESTIMATION suggests the standard process of estimating was followed - all 4 neighbours were repetitively interpolated. ZAMS INSIDER means additional point had to be estimated along the ZAMS track before continuing to the standard estimation method - simply because no lower right neighbour was found in the grid. ZAMS OUTSIDER means that the point lies outside of the graph, but the input values' uncertainties hit inside the graph.

## Text mode
Text mode serves mainly as a debugging tool as it prints intermediate results of the computation. This includes the neighbours used for estimation, evolutionary line, mean value and uncertainties. You can use it from the command line with command

`java -jar file_name.jar text TEMP LUM [TEMPunc LUMunc] [GRID_FILE]`

where TEMP and LUM are input values of effective temperature and luminosity and optional arguments TEMPunc, LUMunc their uncertainties. Missing uncertainties are treated as 0.
Missing grid file argument instructs the application to use the default grid.

![](img/textMode.gif)

## Fast mode
Fast mode can be used for limited, but fully run from command line, computation. This mode processes input file and directly exports result.
The command to run fast mode is following:

`java -jar file_name.jar fast INPUT_FILE [GRID_FILE] EXPORT_FILE_NAME`

where grid file is optional argument and if missing,
default grid is used.
![](img/fastMode.gif)

20 changes: 7 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Stellar Isochrone Fitting Tool

Regular user, head over to the [latest release](https://github.com/Johaney-s/StIFT/releases/latest) and download the .jar file.
Explore, or read the [manual](/Manual.md).
## Overview
StIFT is a tool for estimating stellar characteristics. :sun_with_face:<br />
Methods of estimation are discussed in
Expand All @@ -13,27 +14,20 @@ Methods of estimation are discussed in
- Exporting result data
- Filtering results based on phase
- Filtering tracks based on phase
- Standard deviation estimation
- Error estimation
- Total uncertainty estimation
- Text mode
- Uncertainty estimation
- Text mode, fast mode

## Requirements
Running the application requires Java 11, consider updating JRE in case relevant error message pops up.

## Running the application
Build with `mvn package`.<br />
From the source code, build with `mvn package`.<br />
In target folder run with `java -jar stift-1.0-SNAPSHOT.jar` or open the .jar file directly.

## Detailed description
This app is the topic of my bachelor's thesis at FI MUNI. It should be useful to astrophysicists as some stellar characteristics cannot be directly observed and need to be estimated from known data. The process of estimation is called isochrone fitting and is step by step described in
> MALKOV, O. Yu.; SICHEVSKIJ, S. G.; KOVALEVA, D. A.: "Parametrization of single and binary stars", Monthly Notices of the Royal Astronomical Society. (2009), vol. 401, no. 1: 695. https://doi.org/10.1111/j.1365-2966.2009.15696.x
The grid data is grouped by mass and sorted by evolutionary status (phase). The default grid data is extracted from http://stev.oapd.inaf.it/cgi-bin/cmd containing
The grid data is grouped by mass and sorted by evolutionary status (phase). The default grid data is extracted from [CMD web interface](http://stev.oapd.inaf.it/cgi-bin/cmd) containing
PARSEC and COLIBRI tracks (Marigo et al. (2017)).
After the input is entered, four neighbours are found in the grid data and interpolated for line points estimation. Line points are then interpolated for final result estimation. Error is computed from found neighbours and the standard deviation is estimated from estimations of points created by taking into account input uncertainties. Final uncertainty is the combination of both.

## Text mode
Text mode is available for getting results of computation steps, which includes selected neighbours, line points, mean value, error estimation, estimations for points within the uncertainty area, standard deviation and final uncertainty. To run the text mode, use

`java -jar FILENAME.jar text TEMP LUM [TEMPunc LUMunc] [GRID_FILE]`.
After the input is entered, four neighbours are found in the grid data and interpolated for line points estimation. Line points are then interpolated for final result estimation. The uncertainty is computed from the Monte Carlo simulation on a thousand of points with a normal distribution.
Binary file added img/fastMode.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/gui.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/textMode.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@
<artifactId>controlsfx</artifactId>
<version>11.0.3</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-math3 -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-math3</artifactId>
<version>3.2</version>
</dependency>

<!-- include OS-dependent libraries, see https://stackoverflow.com/questions/52653836/maven-shade-javafx-runtime-components-are-missing -->
<dependency>
<groupId>org.openjfx</groupId>
Expand Down
24 changes: 14 additions & 10 deletions src/main/java/GUI/FXMLLineChartController.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
import java.io.*;
import java.net.URL;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Map;
import java.util.ResourceBundle;
import javafx.application.Platform;
import javafx.beans.property.ObjectProperty;
Expand Down Expand Up @@ -67,7 +65,7 @@ public void graphClicked() {
if (!lineChart.getData().isEmpty()) {
double x = Double.parseDouble(String.format("%.4f", getXMouseCoordinate())); //use showed values in tooltip
double y = Double.parseDouble(String.format("%.4f", getYMouseCoordinate()));
mainController.manageInput(x, y, 0.0, 0.0);
mainController.manageInput(x, y, 0.0, 0.0, (short)2);
}
}

Expand All @@ -91,7 +89,7 @@ public boolean showGraph(InputStream inStream) {
try {
Data newData = GridFileParser.extract(inStream);
lineChart.getData().clear();
addIsochronesToChart(newData.getGroupedData().entrySet().iterator());
addIsochronesToChart(newData.getGroupedData());
} catch (IOException ex) {
mainController.showAlert("Error while parsing grid data", ex.getMessage(), Alert.AlertType.ERROR);
return false;
Expand All @@ -112,20 +110,26 @@ public boolean showGraph(File file) {

/**
* Iterates over groups of stars and adds them into graph as isochrones
* @param iter Iterator of collection of groups of stars
*/
private void addIsochronesToChart(Iterator<Map.Entry<Double, ArrayList<Star>>> iter) {
while (iter.hasNext()) {
Map.Entry<Double, ArrayList<Star>> isochrone = iter.next();
private void addIsochronesToChart(ArrayList<ArrayList<Star>> list) {
int isoCounter = 0;
int MAX_ISOCHRONES = 400;
int SKIPPING_COUNT = list.size() / MAX_ISOCHRONES + 1;
for (ArrayList<Star> isochrone : list) {
isoCounter++;

if (isoCounter % SKIPPING_COUNT != 0) {
continue;
}

Task<Void> task = new Task<Void>() {
@Override
protected Void call() throws Exception {
XYChart.Series series = new XYChart.Series();
int index = 0;
for (Star s : isochrone.getValue()) {
for (Star s : isochrone) {
if (index % 4 != 0) { index++; continue; } //faster rendering
series.getData().add(new XYChart.Data(s.getTemperature(),s.getLuminosity()));
series.getData().add(new XYChart.Data(s.getTemperature(), s.getLuminosity()));
index++;
}

Expand Down
67 changes: 59 additions & 8 deletions src/main/java/GUI/FXMLMainController.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@
import java.io.InputStream;
import java.net.URL;
import java.util.*;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;

import javafx.animation.FadeTransition;
import javafx.application.HostServices;
import javafx.application.Platform;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
Expand Down Expand Up @@ -54,15 +58,22 @@ public class FXMLMainController implements Initializable {
@FXML
private FXMLLoadingController loadingController;
@FXML
private CheckBox includeErrorBox;
@FXML
private CheckBox includeDeviationBox;
@FXML
private GridPane phasePane;
@FXML
private ProgressBar estimationsBar;

ArrayList<CheckBox> allCheckBoxes = new ArrayList<>();
private final FadeTransition fadeIn = new FadeTransition(Duration.millis(1000));

ThreadPoolExecutor executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(1, new ThreadFactory() {
public Thread newThread(Runnable r) {
Thread t = Executors.defaultThreadFactory().newThread(r);
t.setDaemon(true);
return t;
}
}); //terminate threads when exiting application

@Override
public void initialize(URL url, ResourceBundle rb) {

Expand All @@ -84,6 +95,11 @@ public void initialize(URL url, ResourceBundle rb) {
//-- MENU BAR -- File / Edit / Options
@FXML
public void exportDataItemAction() {
if (executor.getQueue().size() > 0) {
showAlert("Running tasks", "Some computations are still running, please wait.", AlertType.INFORMATION);
return;
}

FileChooser fileChooser = new FileChooser();
fileChooser.setTitle("Export data");
FileChooser.ExtensionFilter extFilter = new FileChooser.ExtensionFilter("TXT file (*.txt)", "*.txt");
Expand All @@ -102,6 +118,11 @@ public void exportDataItemAction() {

@FXML
public void uploadNewGridItemAction() {
if (executor.getQueue().size() > 0) {
showAlert("Running tasks", "Some computations are still running, please wait.", AlertType.INFORMATION);
return;
}

if(!tableViewController.getTableModel().isSaved() && !unsavedChangesAlert()) {
return;
}
Expand All @@ -123,6 +144,11 @@ public void uploadNewGridItemAction() {

@FXML
public void uploadInputDataFileAction() {
if (executor.getQueue().size() > 0) {
showAlert("Running tasks", "Some computations are still running, please wait.", AlertType.INFORMATION);
return;
}

if(!tableViewController.getTableModel().isSaved() && !unsavedChangesAlert()) {
return;
}
Expand All @@ -140,6 +166,11 @@ public void uploadInputDataFileAction() {

@FXML
public void resetGridItemAction() {
if (executor.getQueue().size() > 0) {
showAlert("Running tasks", "Some computations are still running, please wait.", AlertType.INFORMATION);
return;
}

if(!tableViewController.getTableModel().isSaved() && !unsavedChangesAlert()) {
return;
}
Expand Down Expand Up @@ -179,6 +210,10 @@ public void aboutItemAction() {

@FXML
public void resetResultsAction() {
if (executor.getQueue().size() > 0) {
showAlert("Running tasks", "Some computations are still running, please wait.", AlertType.INFORMATION);
return;
}
Alert alert = showAlert("Reset results table", "Do you want to reset the results table?",
AlertType.CONFIRMATION);
if (alert.getResult() != null && alert.getResult().equals(ButtonType.OK)) {
Expand All @@ -201,7 +236,9 @@ public void goButtonAction() {
Double inputLumUnc = checkInput(lumUncertaintyField);

if (inputTemVal != null && inputTemUnc != null && inputLumVal != null && inputLumUnc != null) {
manageInput(inputTemVal, inputLumVal, inputTemUnc, inputLumUnc);
String[] splittedUnc = tempUncertaintyField.getText().split("\\.");
short rounding = (splittedUnc.length > 1 && splittedUnc[1].length() > 1) ? (short)splittedUnc[1].length() : 2;
manageInput(inputTemVal, inputLumVal, inputTemUnc, inputLumUnc, rounding);
temperatureField.clear();
tempUncertaintyField.setText("0.0");
luminosityField.clear();
Expand Down Expand Up @@ -283,15 +320,29 @@ public Alert showAlert(String header, String message, AlertType type) {
* @param temp_unc temperature uncertainty
* @param lum_unc temperature uncertainty
*/
public void manageInput(double x, double y, double temp_unc, double lum_unc) {
boolean includeError = includeErrorBox.isSelected();
public void manageInput(double x, double y, double temp_unc, double lum_unc, short rounding) {
boolean includeDeviation = includeDeviationBox.isSelected();
HashSet<Short> ignoredPhases = new HashSet<>();
estimationsBar.setProgress(ProgressIndicator.INDETERMINATE_PROGRESS);

for (CheckBox checkBox : allCheckBoxes) {
if (!checkBox.isSelected()) { ignoredPhases.add(Short.parseShort(checkBox.getText())); }
}
ResultStar result = GridFileParser.getCurrentData().estimate(x, y, temp_unc, lum_unc, includeError, includeDeviation, ignoredPhases);
tableViewController.handleNewResult(result);

Runnable runnable = () -> {
ResultStar result = GridFileParser.getCurrentData().estimate(x, y, temp_unc, lum_unc, includeDeviation, rounding, ignoredPhases);
tableViewController.handleNewResult(result);
if (executor.getQueue().size() > 0) {
Platform.runLater(() -> {
estimationsBar.setProgress(ProgressIndicator.INDETERMINATE_PROGRESS);
});
} else {
Platform.runLater(() -> {
estimationsBar.setProgress(0);
});
}
};
executor.execute(runnable);
}

/**
Expand Down
Loading

0 comments on commit 075b8cd

Please sign in to comment.