Skip to content

Commit

Permalink
Correcting some bugs
Browse files Browse the repository at this point in the history
forecast case :
-> Adding "grid" argument necessary to have regular lat/lon (gaussian otherwise)
-> Adding time of forecast start time (default may not be 00UTC)

Correction on grib_copy command.
  • Loading branch information
wurtzj authored Sep 7, 2022
1 parent 96df42d commit 187e865
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions extractecmwf_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def str_num(i,num_chiffre=2):

#List of dates to extract
#Format AAAAMMDD
LISTE_DATES=["20190723","20190724","20190725","20190726","20190727","20190728","20190729","20190801"]
LISTE_DATES=["20190724","20190725","20190726","20190727","20190728","20190729","20190801"]

#Using ECMWF_DATES enables to collect all dates
#It may not be efficient to extract MESO-NH data
Expand All @@ -42,13 +42,14 @@ def str_num(i,num_chiffre=2):
#output frequency
STEP="1"

FORECAST_START_TIME = "00"

#possibility to remove last step in case of multiple date ?
#END_TIME=str(int(END_TIME)-int(STEP))

HOURS_ECMWF=START_TIME+"/to/"+END_TIME+"/by/"+STEP



#Domain
LAT_MIN="40"
LAT_MAX="52"
Expand Down Expand Up @@ -139,6 +140,9 @@ def str_num(i,num_chiffre=2):
"stream": "oper",
"type": "fc",
"area": AREA_ECMWF,
"grid":GRID_ECMWF,
"time":FORECAST_START_TIME,

},
TARGET_DIRECTORY+OUTPUT_FILE)

Expand All @@ -155,9 +159,15 @@ def str_num(i,num_chiffre=2):
"stream": "oper",
"type": "fc",
"area": AREA_ECMWF,
"grid":GRID_ECMWF,
"time":FORECAST_START_TIME,


},
TARGET_DIRECTORY+OUTPUT_FILE_SFC)

#option "grid":GRID_ECMWF, non necessaire ?

if TYPE=="analysis":
server.execute(
{
Expand Down Expand Up @@ -238,12 +248,16 @@ def str_num(i,num_chiffre=2):


if GET_SURFACE:
os.system("grib_copy " + TARGET_DIRECTORY+OUTPUT_FILE +" " + TARGET_DIRECTORY+OUTPUT_FILE_SFC + " " + TARGET_DIRECTORY+OUTPUT_FILE+"_tempo")
os.system("grib_copy " + TARGET_DIRECTORY+OUTPUT_FILE_SFC +" " + TARGET_DIRECTORY+OUTPUT_FILE + " " + TARGET_DIRECTORY+OUTPUT_FILE+"_tempo")
os.system("rename.ul " + "grib_tempo" + " grib" + TARGET_DIRECTORY+OUTPUT_FILE+"_tempo") #etape may be unusefull but to be sure file is not corrupted


if TYPE=="ensemble":
os.system('grib_copy '+ TARGET_DIRECTORY+OUTPUT_FILE +" " + TARGET_DIRECTORY+ "ecmwf."+TYPE+".[dataDate].[dataTime]h.member.[perturbationNumber].offset.[offsetToEndOf4DvarWindow].grib")
os.system('grib_copy '+ TARGET_DIRECTORY+OUTPUT_FILE+"_tempo" +" " + TARGET_DIRECTORY+ "ecmwf."+TYPE+".[dataDate].[dataTime]h.member.[perturbationNumber].offset.[offsetToEndOf4DvarWindow].grib")
if TYPE=="analysis":
os.system('grib_copy '+ TARGET_DIRECTORY+OUTPUT_FILE+"_tempo" +" " + TARGET_DIRECTORY+ "ecmwf."+TYPE+".[dataDate].[dataTime].grib")
if TYPE=="forecast":
os.system('grib_copy '+ TARGET_DIRECTORY+OUTPUT_FILE+"_tempo" +" " + TARGET_DIRECTORY+ "ecmwf."+TYPE+".[dataDate].[stepRange].grib")



Expand Down

0 comments on commit 187e865

Please sign in to comment.