Skip to content

Commit

Permalink
Add ZAMS option to CLI-fastmode
Browse files Browse the repository at this point in the history
* Added option to specify ZAMS phase when using custom grid in fast mode (CLI)
  • Loading branch information
Johana Supíková committed Jul 30, 2021
1 parent 2b135df commit f31537a
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
38 changes: 36 additions & 2 deletions src/main/java/GUI/FastMode.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import backend.*;

import java.io.*;
import java.util.stream.Collectors;

/** Fast mode performs input file -> export file processing */
public class FastMode {
Expand Down Expand Up @@ -40,17 +41,50 @@ public static void main(String[] args) {
System.out.println("Grid file: default (PARSEC + COLIBRI)");
}
data = GridFileParser.extract(is);

System.out.println("Export file: " + exportFile);

// try to set zams for custom grid
Short phaseZAMS = null;
if (gridFile != null) {
System.out.println("Select ZAMS phase or type [N] to skip: " + data.getCurrentPhases().stream().sorted().collect(Collectors.toList()));
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
while (true) {
Short inputZamsPhase;
String zams = reader.readLine();
if (zams.equalsIgnoreCase("N"))
break;
try {
inputZamsPhase = Short.parseShort(zams);
} catch (NumberFormatException e) {
System.out.println("Incorrect phase. Skip [N] or choose one of the phases included in your data file: "
+ data.getCurrentPhases().stream().sorted().collect(Collectors.toList()));
continue;
}

if (!data.getCurrentPhases().contains(inputZamsPhase)) {
System.out.println("Incorrect phase. Skip [N] or choose one of the phases included in your data file: "
+ data.getCurrentPhases().stream().sorted().collect(Collectors.toList()));
} else {
phaseZAMS = inputZamsPhase;
break;
}
}
}

Settings settings = new Settings();
if (gridFile == null) {
settings.setDefaultSettings();
} else {
settings = new Settings(data.getCurrentPhases(), null, false);
settings = new Settings(data.getCurrentPhases(), phaseZAMS, false);
}
data.applySettings(settings);
Data.setCurrentData(data);
System.out.println("Export file: " + exportFile);

System.out.println("===================================");
System.out.println("Total number of isochrones: " + data.getGroupedData().size());
if (settings.getPhaseZams()!=null)
System.out.println("ZAMS phase: " + settings.getPhaseZams().toString());
TableModel tableModel = new TableModel();
InputFileParser.extract(inputFile, tableModel);
tableModel.exportResults(exportFile);
Expand Down
1 change: 1 addition & 0 deletions src/main/java/GUI/TextOnly.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ public static void main(String[] args) {
data.applySettings(settings);
Data.setCurrentData(data);

System.out.println("===================================");
System.out.println("Total number of isochrones: " + data.getGroupedData().size());
if(settings.getPhaseZams()!=null)
System.out.println("ZAMS phase: " + settings.getPhaseZams().toString());
Expand Down

0 comments on commit f31537a

Please sign in to comment.