Skip to content

Commit

Permalink
Clean prev commit and create neat header #841.
Browse files Browse the repository at this point in the history
  • Loading branch information
treerink committed Feb 13, 2025
1 parent 0a470c9 commit 2dfb6b9
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions ece2cmor3/scripts/convert_varlist_from_cmip6_to_cmip6Plus.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ def load_cmip6_cmip6plus_map_table():
cmip6_cmip6plus_map_table_file_name = os.path.expanduser(file_name_mapping_table)

# Checking if the cmip6-cmip6plus-mapping file exist, if not try to create it:
# if os.path.isfile(cmip6_cmip6plus_map_table_file_name) == False:
if os.path.isfile(cmip6_cmip6plus_map_table_file_name) == True:
if os.path.isfile(cmip6_cmip6plus_map_table_file_name) == False:

# Git checkout of the github wiki table of the mip-cmor-tables if not available
# for converting the github wiki table to an ascii file with columns:
Expand All @@ -44,24 +43,27 @@ def load_cmip6_cmip6plus_map_table():

print('\n Creating the {} neat columnwise ascii file by applying:'.format(file_name_mapping_table))
command_2 = "sed -e '/| CMIP6 table |/,$!d' -e 's/|/ /g' " + wiki_table_file + " | column -t > " + file_name_mapping_table
print(' ' + command_2 + '\n')
print(' ' + command_2)
os.system(command_2)
command_3 = "sed -i -e 's/CMIP6.*/CMIP6 table CMIP6 variable CMIP6Plus Table CMIP6Plus variable Notes/' " + file_name_mapping_table
print(' ' + command_3 + '\n')
os.system(command_3)

if os.path.isfile(cmip6_cmip6plus_map_table_file_name) == False: print(error_message, ' The file ', cmip6_cmip6plus_map_table_file_name, ' does not exist.\n'); sys.exit()

print(' Fix an error in the mip-cmor-tables repo content:')
command_3 = "sed -i -e 's/Apmon/APmon/g' " + file_name_mapping_table
print(' ' + command_3 + '\n')
os.system(command_3)
command_4 = "sed -i -e 's/Apmon/APmon/g' " + file_name_mapping_table
print(' ' + command_4 + '\n')
os.system(command_4)

# Loading the cmip6-cmip6plus-mapping file
cmip6_cmip6plus_map_table = np.loadtxt(cmip6_cmip6plus_map_table_file_name, skiprows=2, usecols=(0,1,2,3), dtype='str')

# Clean:
command_4 = "rm -rf mip-cmor-tables.wiki"
command_5 = "rm -f " + file_name_mapping_table
#os.system(command_4)
#os.system(command_5)
command_5 = "rm -rf mip-cmor-tables.wiki"
command_6 = "rm -f " + file_name_mapping_table
os.system(command_5)
#os.system(command_6)

return cmip6_cmip6plus_map_table

Expand Down

0 comments on commit 2dfb6b9

Please sign in to comment.