Skip to content
Snippets Groups Projects
Commit d8bf41aa authored by Michael Langguth's avatar Michael Langguth
Browse files

Some adaptions to get full path back from metadata-instance when initial...

Some adaptions to get full path back from metadata-instance when initial retrieval of metadata is triggered.
parent 74bbf6ed
No related branches found
No related tags found
No related merge requests found
...@@ -49,10 +49,12 @@ class MetaData: ...@@ -49,10 +49,12 @@ class MetaData:
if not isinstance(variables,list): if not isinstance(variables,list):
raise TypeError(method_name+": 'variables'-argument must be a list.") raise TypeError(method_name+": 'variables'-argument must be a list.")
MetaData.get_and_set_metadata_from_file(suffix_indir,data_filename,slices,variables) curr_dest_dir = MetaData.get_and_set_metadata_from_file(suffix_indir,data_filename,slices,variables)
MetaData.write_metadata_to_file() MetaData.write_metadata_to_file()
return(curr_dest_dir)
def get_and_set_metadata_from_file(self,suffix_indir,datafile_name,slices,variables): def get_and_set_metadata_from_file(self,suffix_indir,datafile_name,slices,variables):
""" """
...@@ -99,26 +101,29 @@ class MetaData: ...@@ -99,26 +101,29 @@ class MetaData:
flag_coords[1] = "W" flag_coords[1] = "W"
nvar = len(variables) nvar = len(variables)
# splitting has to be done in order to avoid the occurence of the year-identifier in the exp_dir-path # splitting has to be done in order to retrieve the expname-suffix (and the year if required)
path_parts = os.path.split(suffix_indir.rstrip("/")) path_parts = os.path.split(suffix_indir.rstrip("/"))
if (is_integer(path_parts[1])): if (is_integer(path_parts[1])):
exp_dir = path_parts[0]
year = path_parts[1] year = path_parts[1]
path_parts = os.path.split(path_parts.rstrip("/"))
else: else:
exp_dir = suffix_indir
year = "" year = ""
expdir, expname = path_parts[0], path_parts[1]
# extend exp_dir_in successively (splitted up for better readability) # extend exp_dir_in successively (splitted up for better readability)
exp_dir += "-"+str(nx) + "x" + str(ny) expname += "-"+str(nx) + "x" + str(ny)
exp_dir += "-"+(("{0: 06.2f}"+flag_coords[0]+"{1: 06.2f}"+flag_coords[1]).format(*sw_c)).strip().replace(".","")+"-" expname += "-"+(("{0: 06.2f}"+flag_coords[0]+"{1: 06.2f}"+flag_coords[1]).format(*sw_c)).strip().replace(".","")+"-"
# reduced for-loop length as last variable-name is not followed by an underscore (see above) # reduced for-loop length as last variable-name is not followed by an underscore (see above)
for i in range(nvar-1): for i in range(nvar-1):
exp_dir += variables[i]+"_" expname += variables[i]+"_"
exp_dir += variables[nvar-1] expname += variables[nvar-1]
self.expname = expname
self.exp_dir = exp_dir return(os.path.join(os.path.join(expdir,expname),year))
# ML 2020/04/24 E # ML 2020/04/24 E
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment