-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRunProperties.java
247 lines (205 loc) · 14.1 KB
/
RunProperties.java
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.scottishseafarms.particle_track;
import java.io.*;
import java.util.Properties;
import static com.scottishseafarms.particle_track.ISO_datestr.dateIntParse;
/**
*
* @author sa01ta
*/
public class RunProperties {
String basedir, sitedir, // Location of code and site data files
datadir, datadirPrefix, datadirSuffix, // Location of default hydrodynamic data, with prefix and suffix for finding annual subdirectories
datadir2, datadir2Prefix, datadir2Suffix, // Location of secondary (larger domain) hydrodynamic data, with prefix and suffix for finding annual subdirectories
mesh1, mesh2, // Full path to the mesh files used describing spatial structure of the hydrodynamic data (
mesh1Type, mesh2Type, // What type of meshes are being read in (FVCOM or ROMS)
restartParticles, // Full path to file containing locations of particles for a hot restart (matches last hour of locations file)
location, sitefile, sitefileEnd, habitat, suffix, species, // Descriptive strings
coordRef; // Coordinate reference system
boolean backwards, // run model backwards? Needs some work on loops to make this work correctly
timeInterpolate, spatialInterpolate, // interpolate between hydro file data values?
rk4, // use RK4 numerical integration (alternative is Euler; need about 10 times as many steps)
parallel, // use multiple cores to speed up run?
diffusion, variableDiff, // include random walk, use diffusion parameter from hydro output?
salinityMort, // mortality calculated based on local salinity (sea lice - doesn't presently do anything)?
endOnArrival, // stop at first suitable habitat site, or simply note arrival and move on?
setStartDepth, fixDepth, // set particle depth at initiation?
readHydroVelocityOnly, // read only u,v from hydro files (saves RAM, ignores random extra variables)
recordPsteps, splitPsteps, // record particle element densities? split by source site?
recordConnectivity, recordLocations, recordArrivals, // record connectivity? particle locations? arrivals at sites?
duplicateLastDay, // Should hydro file for last day be duplicated for interpolation puproses during last hour of simulation (false except when in operational mode)
checkOpenBoundaries, // Should open boundaries be checked? If reading hydro mesh from file directly, the answer is currently NO (open boundaries treated as closed boundaries).
vertInterp; // Should layer velocities be interpolated vertically to particle depth (alternative - old behaviour - is to pick nearest depth)
int start_ymd, end_ymd, numberOfDays, // Start and end of run. If numberOfDays = 0, it is ignored and end_ymd is used instead
releaseScenario, // 0 release all at "releaseTime", 1 continuous release ("nparts" per hour per site)
nparts, // Number of particles released per site (per hour in releaseScenario == 1
recordsPerFile1, // Number of records per velocity file (allow two velocity files with different sizes)
stepsPerStep, // Number of increments between each velocity record (also for time interpolations)
//depthLayers, // Number of depth layers in hydro output - IDEALLY DEPRECATE
thresh, // Threshold distance for "settlement" (m)
behaviour, // Particle behaviour - see Particle.java
parallelThreads, // Number of threads to use in parallel execution
minchVersion, // Another element of the filename for hydrodynamic files
pstepsInterval, connectivityInterval; // Interval in hours between recording element density summaries, and connectivity
double releaseTime, releaseTimeEnd, viabletime, // Time of particle release (if releaseScenario == "0") and end of particle release (if releaseScenario == 2), Time to attain settlement competency
dt, // Timestep (s) per record
D_h, // Horizontal diffuision parameter
D_hVert, // Vertical diffuision parameter
mortalityRate, // Hourly mortality rate of particles
maxParticleAge, // Maximum age for particles. Set to <=0 and it will be ignored.
viableDegreeDays,maxDegreeDays, // Degree x days to use for settlement viability time and mortality
sinkingRateMean, sinkingRateStd, // Particle sinking distribution parameters
vertSwimSpeedMean, vertSwimSpeedStd,
salinityThreshold,
startDepth, // Particle initiation depth
restartParticlesCutoffDays, // when reading the specified restart particles file, cutoff in particle start date to apply (days before start date of run)
velocityScale; // Numerical scaling of velocity for horizontal particle movement
/**
*
* @param filename
*/
public RunProperties(String filename)
{
System.out.println("GETTING PROPERTIES FROM "+filename);
Properties properties = new Properties();
try
{
properties.load(new FileInputStream(filename));
}
catch (IOException e)
{
System.err.println("!!!Could not find properties file!!!");
}
for(String key : properties.stringPropertyNames()) {
String value = properties.getProperty(key);
System.out.println(key + " => " + value);
}
basedir = properties.getProperty("basedir","/home/sa01ta/particle_track/");
sitedir = properties.getProperty("sitedir","/home/sa01ta/particle_track/minch_sites/");
datadir = properties.getProperty("datadir","/home/sa01da/work/minch2/Archive/");
datadirPrefix = properties.getProperty("datadirPrefix","netcdf_");
datadirSuffix = properties.getProperty("datadirSuffix","");
datadir2 = properties.getProperty("datadir2","/home/sa01da/data/oss/");
datadir2Prefix = properties.getProperty("datadirPrefix","");
datadir2Suffix = properties.getProperty("datadirSuffix","_OLD");
minchVersion = Integer.parseInt(properties.getProperty("minchVersion","2"));
mesh1 = properties.getProperty("mesh1","/home/sa01ta/particle_track/WestCOMS_mesh.nc");
mesh2 = properties.getProperty("mesh2","");
mesh1Type = properties.getProperty("mesh1Type","");
mesh2Type = properties.getProperty("mesh2Type","");
checkOpenBoundaries = Boolean.parseBoolean(properties.getProperty("checkOpenBoundaries","false"));
restartParticles = properties.getProperty("restartParticles","");
restartParticlesCutoffDays = Double.parseDouble(properties.getProperty("restartParticlesCutoffDays","21"));
sitefile = properties.getProperty("sitefile","startlocations.dat");
sitefileEnd = properties.getProperty("sitefileEnd",sitefile);
location = properties.getProperty("location","minch");
habitat = properties.getProperty("habitat","");
suffix = properties.getProperty("suffix","");
coordRef = properties.getProperty("coordRef","WGS84");
start_ymd = Integer.parseInt(properties.getProperty("start_ymd","20180101"));
numberOfDays = Integer.parseInt(properties.getProperty("numberOfDays","0"));
if (numberOfDays>0)
{
int[] startDate = ISO_datestr.dateIntParse(start_ymd);
ISO_datestr tempIsoDate = new ISO_datestr(startDate[0], startDate[1], startDate[2]);
for (int i = 1; i < numberOfDays; i++)
{
tempIsoDate.addDay();
}
end_ymd = Integer.parseInt(tempIsoDate.getDateStr());
}
else
{
end_ymd = Integer.parseInt(properties.getProperty("end_ymd","20180102"));
}
if (end_ymd<start_ymd)
{
System.err.println("***** End date before start date! *****");
System.exit(1);
}
// Set variable values based on contents of the properties object
backwards = Boolean.parseBoolean(properties.getProperty("backwards","false"));
// DEPRECATED
//timeInterpolate = Boolean.parseBoolean(properties.getProperty("timeInterpolate","true"));
//spatialInterpolate = Boolean.parseBoolean(properties.getProperty("spatialInterpolate","true"));
rk4 = Boolean.parseBoolean(properties.getProperty("rk4","true"));
diffusion = Boolean.parseBoolean(properties.getProperty("diffusion","true"));
variableDiff = Boolean.parseBoolean(properties.getProperty("variableDiff","false"));
salinityMort = Boolean.parseBoolean(properties.getProperty("salinityMort","false"));
endOnArrival = Boolean.parseBoolean(properties.getProperty("endOnArrival","false"));
// DEPRECATED
//tidalRelease = Boolean.parseBoolean(properties.getProperty("tidalRelease","false"));
setStartDepth = Boolean.parseBoolean(properties.getProperty("setStartDepth","false"));
fixDepth = Boolean.parseBoolean(properties.getProperty("fixDepth","false"));
startDepth = Integer.parseInt(properties.getProperty("startDepth","0"));
vertInterp = Boolean.parseBoolean(properties.getProperty("vertInterp","true"));
readHydroVelocityOnly = Boolean.parseBoolean(properties.getProperty("readHydroVelocityOnly","false"));
if (vertInterp == true && readHydroVelocityOnly == true)
{
System.err.println("If using vertical interpolation, must read all hydro fields; setting readHydroVelocityOnly to FALSE");
readHydroVelocityOnly = false;
}
velocityScale = Double.parseDouble(properties.getProperty("velocityScale","1"));
duplicateLastDay = Boolean.parseBoolean(properties.getProperty("duplicateLastDay","false"));
parallel = Boolean.parseBoolean(properties.getProperty("parallel","true"));
parallelThreads = Integer.parseInt(properties.getProperty("parallelThreads","4"));
// DEPRECATED
//oldOutput = Boolean.parseBoolean(properties.getProperty("oldOutput"));
recordPsteps = Boolean.parseBoolean(properties.getProperty("recordPsteps","true"));
splitPsteps = Boolean.parseBoolean(properties.getProperty("splitPsteps","true"));
pstepsInterval = Integer.parseInt(properties.getProperty("pstepsInterval","24"));
recordConnectivity = Boolean.parseBoolean(properties.getProperty("recordConnectivity","true"));
connectivityInterval = Integer.parseInt(properties.getProperty("connectivityInterval","24"));
recordLocations = Boolean.parseBoolean(properties.getProperty("recordLocations","true"));
recordArrivals = Boolean.parseBoolean(properties.getProperty("recordArrivals","true"));
releaseScenario = Integer.parseInt(properties.getProperty("releaseScenario","0"));
nparts = Integer.parseInt(properties.getProperty("nparts","5"));
releaseTime = Double.parseDouble(properties.getProperty("releaseTime","0"));
releaseTimeEnd = Double.parseDouble(properties.getProperty("releaseTimeEnd","24"));
dt = Double.parseDouble(properties.getProperty("dt","3600"));
// 21/11/2018 --- Ideally want to remove this. If using two models for hydro
// would ideally sense from the hydro file
recordsPerFile1 = Integer.parseInt(properties.getProperty("recordsPerFile1","25"));
//recordsPerFile2 = Integer.parseInt(properties.getProperty("recordsPerFile2","4"));
stepsPerStep = Integer.parseInt(properties.getProperty("stepsPerStep","25"));
// 21/11/2018 --- possible to remove? If using two models for hydro
// would ideally sense from the hydro file
//depthLayers = Integer.parseInt(properties.getProperty("depthLayers","10"));
thresh = Integer.parseInt(properties.getProperty("thresh","500"));
behaviour = Integer.parseInt(properties.getProperty("behaviour","1"));
D_h = Double.parseDouble(properties.getProperty("D_h","0.1"));
D_hVert = Double.parseDouble(properties.getProperty("D_hVert","0.005"));
mortalityRate = Double.parseDouble(properties.getProperty("mortalityRate","0.01"));
species = properties.getProperty("species","none");
viabletime = Double.parseDouble(properties.getProperty("viabletime","86"));
maxParticleAge = Double.parseDouble(properties.getProperty("maxParticleAge","336"));
viableDegreeDays = Double.parseDouble(properties.getProperty("viableDegreeDays","-1"));
maxDegreeDays = Double.parseDouble(properties.getProperty("maxDegreeDays","-1"));
if (viableDegreeDays != -1)
{
//viabletime = viableDegreeDays*20;
viabletime = -1;
System.out.println("viableDegreeDays entered; set viabletime="+viabletime+" so won't be used at 56N!");
}
if (maxDegreeDays != -1)
{
//maxParticleAge = maxDegreeDays*20;
maxParticleAge = -1;
System.out.println("maxDegreeDays entered; set maxParticleAge="+maxParticleAge+" so won't be used at 56N!");
}
if ((viableDegreeDays != -1 || maxParticleAge != -1) && readHydroVelocityOnly == true)
{
System.err.println("readHydroVelocityOnly==true AND trying to use degree-days for development => won't develop or die!");
}
vertSwimSpeedMean = Double.parseDouble(properties.getProperty("vertSwimSpeedMean","0"));
vertSwimSpeedStd = Double.parseDouble(properties.getProperty("vertSwimSpeedStd","0"));
sinkingRateMean = Double.parseDouble(properties.getProperty("sinkingRateMean","0"));
sinkingRateStd = Double.parseDouble(properties.getProperty("sinkingRateStd","0"));
salinityThreshold = Double.parseDouble(properties.getProperty("salinityThreshold","0"));
properties.list(System.out);
}
}