Skip to content

Commit f73e05a

Browse files
author
stnieble
committed
cleanup
1 parent 1129439 commit f73e05a

File tree

5 files changed

+11
-75
lines changed

5 files changed

+11
-75
lines changed

ClipCreation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,15 @@ def parseArguments():
5050
parser.add_argument('--disable-cuda', action='store_true', help='Disable CUDA')
5151
parser.add_argument('--device', type = int, default = 0, help = "number of device to use")
5252
parser.add_argument('--fullsize', action='store_true', help='test the network at the global scope')
53-
parser.add_argument('--preCalc', action='store_true', help='test the network at the global scope')
53+
parser.add_argument('--preCalc', action='store_true', help='use precalculated binaries as input')
5454
parser.add_argument('--NWS', action = 'store_true', help='use Resolution of hires')
5555
parser.add_argument('--num_samples', type = int, default = -1, help='number of samples to infere from the dataset')
5656
parser.add_argument('--classes', type = int, default = 1, help = 'How many classes the network should predict (binary case has 1 class denoted by probabilities)')
5757
parser.add_argument('--normType', type = int, default = 0, help = 'How to normalize the data: 0 min-max, 1 mean-var, 2/3 the same but per pixel')
5858
parser.add_argument('--labelGroupingList', type = str, default = None, help = 'Comma separated list of label groups \n possible fields are w c o s (warm, cold, occluson, stationary)')
5959
parser.add_argument('--ETH', action = 'store_true', help = 'Compare against an ETH result instead of net')
6060
parser.add_argument('--show-error', action = 'store_true', help = 'show the inividual error values during inference')
61-
parser.add_argument('--fromFile', type = str, default = None, help = 'show the inividual error values during inference')
61+
parser.add_argument('--fromFile', type = str, default = None, help = 'file to extract network configuration from')
6262
parser.add_argument('--calcVar', type = str, default = "t", help = 'which variable to measure along the cross section')
6363
parser.add_argument('--secPath', type = str, default = None, help = 'Path to folder with secondary data containing variable information to be evaluated. Data should be stored as <secPath>/YYYY/MM/<fileID>YYYYMMDD_HH.nc . <fileID> is an Identifier based on the type of file (e.g. B,Z,precip)')
6464
parser.add_argument('--alpha', type = float, default = 0, help='weight of constant background compared background variable. [0 to 1]')

FrontalCrossSection.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,14 @@ def parseArguments():
5757
parser.add_argument('--disable-cuda', action='store_true', help='Disable CUDA')
5858
parser.add_argument('--device', type = int, default = 0, help = "number of device to use")
5959
parser.add_argument('--fullsize', action='store_true', help='test the network at the global scope')
60-
parser.add_argument('--preCalc', action='store_true', help='test the network at the global scope')
60+
parser.add_argument('--preCalc', action='store_true', help='use precalculated binaries as input')
6161
parser.add_argument('--NWS', action = 'store_true', help='use Resolution of hires')
6262
parser.add_argument('--num_samples', type = int, default = -1, help='number of samples to infere from the dataset')
6363
parser.add_argument('--classes', type = int, default = 1, help = 'How many classes the network should predict (binary case has 1 class denoted by probabilities)')
6464
parser.add_argument('--normType', type = int, default = 0, help = 'How to normalize the data: 0 min-max, 1 mean-var, 2/3 the same but per pixel')
6565
parser.add_argument('--labelGroupingList', type = str, default = None, help = 'Comma separated list of label groups \n possible fields are w c o s (warm, cold, occluson, stationary)')
6666
parser.add_argument('--show-error', action = 'store_true', help = 'show the inividual error values during inference')
67-
parser.add_argument('--fromFile', type = str, default = None, help = 'show the inividual error values during inference')
67+
parser.add_argument('--fromFile', type = str, default = None, help = 'file to extract network configuration from')
6868
parser.add_argument('--calcType', type = str, default = "ML", help = 'from which fronts should the crossing be calculated')
6969
parser.add_argument('--calcVar', type = str, default = "t", help = 'which variable to measure along the cross section')
7070
parser.add_argument('--secPath', type = str, default = None, help = 'Path to folder with secondary data containing variable information to be evaluated. Data should be stored as <secPath>/YYYY/MM/<fileID>YYYYMMDD_HH.nc . <fileID> is an Identifier based on the type of file (e.g. ml,B,Z,precip)')

GeneralInference.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -536,12 +536,12 @@ def parseArguments():
536536

537537
# inference information
538538
parser.add_argument('--ETH', action = 'store_true', help = 'Compare against an ETH result instead of net')
539-
parser.add_argument('--preCalc', action = 'store_true')
539+
parser.add_argument('--preCalc', action = 'store_true', help = 'use precalculated binaries as input')
540540

541541
# network information
542542
parser.add_argument('--net', help='path no net')
543543
parser.add_argument('--classes', type = int, default = 1, help = 'How many classes the network should predict (binary case has 1 class denoted by probabilities)')
544-
parser.add_argument('--fromFile', type = str, default = None, help = 'show the inividual error values during inference')
544+
parser.add_argument('--fromFile', type = str, default = None, help = 'file to extract network configuration from')
545545

546546
# evaluation information
547547
parser.add_argument('--CSI', action = 'store_true', help = 'evaluate the CSI')

InferOutputs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def parseArguments():
4848
parser.add_argument('--classes', type = int, default = 1, help = 'How many classes the network should predict (binary case has 1 class denoted by probabilities)')
4949
parser.add_argument('--normType', type = int, default = 0, help = 'How to normalize the data: 0 min-max, 1 mean-var, 2/3 the same but per pixel')
5050
parser.add_argument('--labelGroupingList', type = str, default = None, help = 'Comma separated list of label groups \n possible fields are w c o s (warm, cold, occluson, stationary)')
51-
parser.add_argument('--fromFile', type = str, default = None, help = 'show the inividual error values during inference')
51+
parser.add_argument('--fromFile', type = str, default = None, help = 'file to extract network configuration from')
5252
parser.add_argument('--border', type = int, default = 5, help = "A Border in degree which is not evaluated")
5353
parser.add_argument('--skip', type = int, default = 0, help = "How many of the data should be skipped (skip + not skipped = num_samples)")
5454
args = parser.parse_args()

era5dataset/ERA5Reader/readNetCDF.py

Lines changed: 4 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ def getNormalizationMaskshm(self, variable, latrange, lonrange, levelrange, date
246246
year,month,day,hour = date
247247
target_name = variable+"_m"+str(int(month))+"_h"+str(int(hour))+".bin"
248248

249-
pathToMasks = self.pathToMasks#os.path.join("/home","stefan","Documents","Binary","Front-Detection","myTrainingScripts","era5dataset")
249+
pathToMasks = self.pathToMasks
250250
if(type == 0):
251251
mask_file_string1 = os.path.join(pathToMasks,"statimgs","min",target_name)
252252
mask_file_string2 = os.path.join(pathToMasks,"statimgs","max",target_name)
@@ -783,78 +783,14 @@ def scaleArray(data, scal_fac, add_off):
783783
data += add_off
784784

785785
def dewpointTemp(temp, humidity, level_range = slice(0,6,1)):
786-
K3 = 243.12
787-
K2 = 17.62
788-
K1 = 6.112
789-
cels = temp-273.15
790-
psaett = K1 * np.exp((K2*cels)/(K3+cels))
791-
PaPerLevel = [722.9795, 795.6396, 856.8376, 986.6036, 1002.2250, 1013.2500]
792-
PaPerLevel = PaPerLevel[level_range]
793-
#PaPerLevel = [986.6036, 1002.2250, 1013.2500]
794-
#PaPerLevel = [722.9795, 795.6396, 856.8376]
795-
#ph = np.zeros(humidity.shape)
796-
S = np.zeros_like(humidity)
797-
for i in range(len(PaPerLevel)):
798-
#ph[i] = humidity[i]*PaPerLevel[i]
799-
S[i] = 0.622*psaett[i] / ((PaPerLevel[i]-0.378*psaett[i]))
800-
relHum = humidity/S
801-
lnh = np.log(relHum, where=(relHum>0))
802-
803-
#dewP1 = K3* np.log((ph)/((0.622+humidity)*K1))
804-
#dewP2 = K2 - np.log((ph)/((0.622+humidity)*K1))
805-
#dewP = dewP1/dewP2
806-
#divisor = K3+cels
807-
808-
dewP1 = K2*cels / (K3+cels) + lnh
809-
dewP2 = K2*K3 / (K3+cels) - lnh
810-
811-
dewP = K3* dewP1/dewP2
812-
return dewP
786+
pass
813787

814788
def equivalentPotentialTempNew(temp, humidity, PaPerLevel):
815-
816-
cp = 1004.82
817-
Rd = 287.05
818-
equiPotTemp = temp[:]
819-
L = 2257000
820-
m = humidity
821-
PaPerLevel = [722.9795, 795.6396, 856.8376, 986.6036, 1002.2250, 1013.2500]
822-
#PaPerLevel = PaPerLevel[level_range]
823-
for i in range(len(PaPerLevel)):
824-
equiPotTemp[i] *= pow((1000/PaPerLevel[i]), Rd/cp)*np.exp(L*m[i] / (cp*temp[i]))
825-
return equiPotTemp
789+
pass
826790

827791

828792
def equivalentPotentialTemp(t, q, PaPerLevel):
829-
#pu = units.Quantity(p, "Pa")
830-
#tu = units.Quantity(t, "K")
831-
#dewp = dewpoint_from_specific_humidity(pu, tu, q)
832-
#return equivalent_potential_temperature(pu, tu, dewp)
833-
'''
834-
# celsius temp
835-
ctemp = t-273.15
836-
837-
# constants
838-
cp = 1.00482
839-
cw = 4.18674
840-
Rd = 287.05
841-
842-
# L value
843-
L = 2500.78-2.325734*ctemp
844-
845-
#equivalent temp
846-
ctemp += q*(L/(cp+q*cw)) + 273.15
847-
848-
# precalculate exponent
849-
cp *= 1000
850-
val = Rd/cp
851-
852-
#equivalent potential temp (this is very slow! approx 3.5 seconds)
853-
# multiplication by 100 to get Pa out of hPa
854-
ctemp *= np.power(100000/PaPerLevel, val)
855-
856-
return ctemp
857-
'''
793+
pass
858794

859795
def getValueRanges(variable):
860796
minval,maxval = 0,1

0 commit comments

Comments
 (0)