From 37c314ca547c2c82611d8ae177367dc2a8e86041 Mon Sep 17 00:00:00 2001 From: Cosimo Palazzo Date: Wed, 21 Sep 2016 19:57:50 +0200 Subject: [PATCH] Fix image scaling for INDIGO --- .../precip_trend_analysis.json | 30 +++++++---- .../precip_trend_analysis_ensemble.json | 7 +-- .../script/precip_trend_analysis.py | 50 ++++++------------- .../script/precip_trend_analysis.sh | 13 +++-- .../script/precip_trend_analysis_ensemble.py | 36 +------------ 5 files changed, 50 insertions(+), 86 deletions(-) diff --git a/indigo/precip_trend_analisys/precip_trend_analysis.json b/indigo/precip_trend_analisys/precip_trend_analysis.json index 2d615fb..021bc95 100644 --- a/indigo/precip_trend_analisys/precip_trend_analysis.json +++ b/indigo/precip_trend_analisys/precip_trend_analysis.json @@ -1,7 +1,7 @@ { "name": "precip_trend_analysis", "author": "CMCC Foundation", - "abstract": "Workflow for the analysis of precipitation trends related to different scenarios. ${1} is ncores; ${2} is the model (e.g. CMCC-CM); ${3} is the scenario (e.g. rcp85); ${4} is the frequency (e.g. day); ${5} is the percentile (e.g. 0.9); ${6} is the past time subset (e.g. 1976_2006); ${7} is the future time subset (e.g. 2071_2101); ${8} is the geographic subset (e.g. 30:45|0:40); ${9} is the grid of output map using the format rx (e.g. r360x180), i.e. a global regular lon/lat grid (this parameter is optional and by default the lon/lat grid of input file is adopted); ${10} import type, set to '1' in case only subsetting data have to be imported (optional).", + "abstract": "Workflow for the analysis of precipitation trends related to different scenarios. ${1} is ncores; ${2} is the model (e.g. CMCC-CM); ${3} is the scenario (e.g. rcp85); ${4} is the frequency (e.g. day); ${5} is the percentile (e.g. 0.9); ${6} is the past time subset (e.g. 1976_2006); ${7} is the future time subset (e.g. 2071_2101); ${8} is the geographic subset (e.g. 30:45|0:40); ${9} is the grid of output map using the format rx (e.g. r360x180), i.e. a global regular lon/lat grid (this parameter is optional and by default the lon/lat grid of input file is adopted); ${10} import type, set to '1' in case only subsetting data have to be imported (optional); ${11} I/O server type.", "exec_mode": "sync", "cwd": "/", "ncores": "${1}", @@ -50,7 +50,7 @@ }, { "name": "Import Historical", - "operator": "oph_importnc", + "operator": "oph_importnc3", "arguments": [ "container=historical", "exp_dim=lat|lon", @@ -69,7 +69,9 @@ "units=d", "subset_dims=time|lat|lon", "subset_filter=${6}|${8}", - "subset_type=coord" + "subset_type=coord", + "offset=0|2|2", + "ioserver=${11}" ], "dependencies": [ { "task": "Import Type Selection Historical" } @@ -85,7 +87,7 @@ }, { "name": "Import Historical Only", - "operator": "oph_importnc", + "operator": "oph_importnc3", "arguments": [ "container=historical", "exp_dim=lat|lon", @@ -101,7 +103,8 @@ "nhost=1", "import_metadata=yes", "check_compliance=no", - "units=d" + "units=d", + "ioserver=${11}" ], "dependencies": [ { "task": "Import without subsetting Historical" } @@ -112,7 +115,8 @@ "operator": "oph_subset2", "arguments": [ "subset_dims=time|lat|lon", - "subset_filter=${6}|${8}" + "subset_filter=${6}|${8}", + "offset=0|2|2" ], "dependencies": [ { "task": "Import Historical Only", "type": "single" } @@ -188,7 +192,7 @@ }, { "name": "Import Scenario", - "operator": "oph_importnc", + "operator": "oph_importnc3", "arguments": [ "container=scenario", "exp_dim=lat|lon", @@ -207,7 +211,9 @@ "units=d", "subset_dims=time|lat|lon", "subset_filter=${7}|${8}", - "subset_type=coord" + "subset_type=coord", + "offset=0|2|2", + "ioserver=${11}" ], "dependencies": [ { "task": "Import Type Selection Scenario" } @@ -223,7 +229,7 @@ }, { "name": "Import Scenario Only", - "operator": "oph_importnc", + "operator": "oph_importnc3", "arguments": [ "container=scenario", "exp_dim=lat|lon", @@ -239,7 +245,8 @@ "nhost=1", "import_metadata=yes", "check_compliance=no", - "units=d" + "units=d", + "ioserver=${11}" ], "dependencies": [ { "task": "Import without subsetting Scenario" } @@ -250,7 +257,8 @@ "operator": "oph_subset2", "arguments": [ "subset_dims=time|lat|lon", - "subset_filter=${7}|${8}" + "subset_filter=${7}|${8}", + "offset=0|2|2" ], "dependencies": [ { "task": "Import Scenario Only", "type": "single" } diff --git a/indigo/precip_trend_analisys/precip_trend_analysis_ensemble.json b/indigo/precip_trend_analisys/precip_trend_analysis_ensemble.json index f7d6ea5..bc29325 100644 --- a/indigo/precip_trend_analisys/precip_trend_analysis_ensemble.json +++ b/indigo/precip_trend_analisys/precip_trend_analysis_ensemble.json @@ -1,7 +1,7 @@ { "name": "Ensemble analysis related to precipitation trend analysis", "author": "CMCC", - "abstract": "Usage: /path/precip_trend_analysis_ensemble.json file1.nc|file2.nc. The parameter is the list of (OPeNDAP URLs to) NC files to be analyzed.", + "abstract": "Usage: /path/precip_trend_analysis_ensemble.json file1.nc|file2.nc . ${1} is the list of (OPeNDAP URLs to) NC files to be analyzed; ${2} is I/O server type.", "exec_mode": "sync", "ncores": "1", "on_exit":"oph_delete", @@ -51,7 +51,7 @@ }, { "name": "import", - "operator": "oph_importnc2", + "operator": "oph_importnc3", "arguments": [ "cwd=/", "measure=precip_trend", @@ -59,7 +59,8 @@ "import_metadata=yes", "nfrag=1", "container=ensemble", - "grid=map" + "grid=map", + "ioserver=${2}" ], "dependencies": [ { diff --git a/indigo/precip_trend_analisys/script/precip_trend_analysis.py b/indigo/precip_trend_analisys/script/precip_trend_analysis.py index effc2de..73ff36e 100644 --- a/indigo/precip_trend_analisys/script/precip_trend_analysis.py +++ b/indigo/precip_trend_analisys/script/precip_trend_analysis.py @@ -16,6 +16,10 @@ InFile = "/".join([DataDir, "precip_trend_analysis.nc"]) OutFile = "/".join([DataDir, "precip_trend_analysis.png"]) +Lats = sys.argv[3] + +Lons = sys.argv[4] + # Process file f = cdms2.open(InFile) @@ -39,39 +43,6 @@ iso.fillareacolors = cols iso.legend = vcs.mklabels(numpy.arange(-3, 3.01, .375)) -# iso.list() - -# Prettify ticks -# bottom -iso.xticlabels1 = "Lon30" # vcs predefined list -# sub ticks -iso.xmtics1 = "lon10_0" -# left -dic = {} -for i in range(-90, 91, 30): - if i < 0: - dic[i] = "%iS" % (-i) - elif i > 0: - dic[i] = "%iN" % i - else: - dic[i] = "Eq" -iso.yticlabels1 = dic -iso.ymtics1 = "lat10_0" - -# top -# First create dic with empty ticks -dic = {} -for i in range(-90, 370, 30): - dic[i] = "" -iso.xticlabels2 = dic -# right -iso.yticlabels2 = dic - -dic = {} -for i in range(-100, 370, 10): - dic[i] = "" -iso.ymtics2 = dic -iso.xmtics2 = dic # Now create a template to move things around a bit t = x.createtemplate() @@ -80,8 +51,17 @@ t.ymintic1.priority = 1 # turn on left sub ticks t.ymintic2.priority = 1 # turn on right sub ticks -t.scale(.9, "x") -t.moveto(.05, .2) +if Lons < 1.2*Lats: + t.scale(.9 * Lons / (2 * Lats), "x") + t.scale(1.5, "y") +elif Lons < 2*Lats: + t.scale(.9, "x") + t.scale(1.8 * Lats / Lons, "y") +else: + t.scale(.9, "x") + t.scale(.9, "y") +t.moveto(.05, .1) + # Move legend t.legend.x1 = t.data.x2 + .03 t.legend.x2 = t.legend.x1 + .03 diff --git a/indigo/precip_trend_analisys/script/precip_trend_analysis.sh b/indigo/precip_trend_analisys/script/precip_trend_analysis.sh index 36e3f8f..dfa3a89 100755 --- a/indigo/precip_trend_analisys/script/precip_trend_analysis.sh +++ b/indigo/precip_trend_analisys/script/precip_trend_analysis.sh @@ -19,6 +19,9 @@ RelWorkDir="`dirname \"$0\"`" AbsWorkDir="`( cd \"$RelWorkDir\" && pwd )`" InFile=$OPH_SCRIPT_SESSION_PATH/$OPH_SCRIPT_WORKFLOW_ID/$FileName +LATS=180 +LONS=360 + # Bilinear regridding if [ "$NewGrid" != "" ]; then @@ -29,8 +32,10 @@ XFIRST=${LonRange%%:*} YFIRST=${LatRange%%:*} XLAST=${LonRange##*:} YLAST=${LatRange##*:} -XINC=`echo "(($XLAST)-($XFIRST))/($XSIZE)" | bc -l` -YINC=`echo "(($YLAST)-($YFIRST))/($YSIZE)" | bc -l` +LATS=`echo "($YLAST)-($YFIRST)" | bc -l` +LONS=`echo "($XLAST)-($XFIRST)" | bc -l` +XINC=`echo "($LONS)/($XSIZE)" | bc -l` +YINC=`echo "($LATS)/($YSIZE)" | bc -l` let XSIZE+=1 let YSIZE+=1 @@ -66,8 +71,10 @@ cp $InFile $BasePath/$OPH_SCRIPT_SESSION_CODE/$OPH_SCRIPT_WORKFLOW_ID/ 2>&1 > /d # Create and publish UV-CDAT map source activate $UVCDATenv -python $AbsWorkDir/precip_trend_analysis.py $AbsWorkDir $OPH_SCRIPT_SESSION_PATH/$OPH_SCRIPT_WORKFLOW_ID/ +python $AbsWorkDir/precip_trend_analysis.py $AbsWorkDir $OPH_SCRIPT_SESSION_PATH/$OPH_SCRIPT_WORKFLOW_ID/ $LATS $LONS source deactivate +cp $OPH_SCRIPT_SESSION_PATH/$OPH_SCRIPT_WORKFLOW_ID/precip_trend_analysis.png $BasePath/$OPH_SCRIPT_SESSION_CODE/$OPH_SCRIPT_WORKFLOW_ID/ + exit 0 diff --git a/indigo/precip_trend_analisys/script/precip_trend_analysis_ensemble.py b/indigo/precip_trend_analisys/script/precip_trend_analysis_ensemble.py index 6cb4dd7..2cd66c6 100644 --- a/indigo/precip_trend_analisys/script/precip_trend_analysis_ensemble.py +++ b/indigo/precip_trend_analisys/script/precip_trend_analysis_ensemble.py @@ -41,39 +41,6 @@ iso.fillareacolors = cols iso.legend = vcs.mklabels(numpy.arange(-3, 3.01, .375)) -# iso.list() - -# Prettify ticks -# bottom -iso.xticlabels1 = "Lon30" # vcs predefined list -# sub ticks -iso.xmtics1 = "lon10_0" -# left -dic = {} -for i in range(-90, 91, 30): - if i < 0: - dic[i] = "%iS" % (-i) - elif i > 0: - dic[i] = "%iN" % i - else: - dic[i] = "Eq" -iso.yticlabels1 = dic -iso.ymtics1 = "lat10_0" - -# top -# First create dic with empty ticks -dic = {} -for i in range(-90, 370, 30): - dic[i] = "" -iso.xticlabels2 = dic -# right -iso.yticlabels2 = dic - -dic = {} -for i in range(-100, 370, 10): - dic[i] = "" -iso.ymtics2 = dic -iso.xmtics2 = dic # Now create a template to move things around a bit t = x.createtemplate() @@ -83,7 +50,8 @@ t.ymintic2.priority = 1 # turn on right sub ticks t.scale(.9, "x") -t.moveto(.05, .2) +t.scale(1.8, "y") +t.moveto(.05, .1) # Move legend t.legend.x1 = t.data.x2 + .03 t.legend.x2 = t.legend.x1 + .03