Class for normalizing data. The statistical data for normalization (minimum, maximum, average, standard deviation etc.) is expected to be available from a statistics-dictionary
created with the calc_data_stat-class (see 'process_netCDF_v2.py'.
"""
### set known norms and the requested statistics (to be retrieved from statistics.json) here ###
known_norms={}
known_norms["minmax"]=["min","max"]
known_norms["znorm"]=["avg","sigma"]
def__init__(self,varnames):
"""Initialize the instance by setting the variable names to be handled and the status (for sanity checks only) as attributes."""
varnames_uni,_,nvars=get_unique_vars(varnames)
self.varnames=varnames_uni
self.status_ok=False
defcheck_and_set_norm(self,stat_dict,norm):
"""
Checks if the statistics-dictionary provides the required data for selected normalization method and expands the instance's attributes accordingly.
Example: minmax-normalization requires the minimum and maximum value of a variable named var1.
If the requested values are provided by the statistics-dictionary, the instance gets the attributes 'var1min' and 'var1max',respectively.
defread_frames_and_save_tf_records(output_dir,input_dir,partition_name,vars_in,seq_length=20,sequences_per_file=128,height=64,width=64,channels=3,**kwargs):#Bing: original 128
defread_frames_and_save_tf_records(output_dir,input_dir,partition_name,vars_in,seq_length=20,sequences_per_file=128,height=64,width=64,channels=3,**kwargs):#Bing: original 128
# ML 2020/04/08:
# ML 2020/04/08:
# Include vars_in for more flexible data handling (normalization and reshaping)
# Include vars_in for more flexible data handling (normalization and reshaping)
# and optional keyword argument for kind of normalization
# and optional keyword argument for kind of normalization
known_norms=["minmax"]# may be more elegant to define a class here?