Re: crappy png output

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Thu Oct 20 2011 - 14:13:11 MDT

Ugo,

The first download link you provided gave me some files that have nothing to do with NCL. They are from "Avid Media Composer".

Can you provide an example of "crappy PNG output"?

I tried to run your script, but got some errors in a couple of your "if" statements, because your system date
command appears to be outputting Italian, and ours is in English.

Can you provide a smaller script that shows the problem?

--Mary

On Oct 20, 2011, at 1:08 PM, ugo merlini wrote:

> Hi,
>
> i discover that outut on png is very crappy
>
> I use the same script with the exception of the output format
>
> output file downloadable from mediafire http://www.mediafire.com/?bd6xy1d8bj6877m
>
> if you want download the shapefile I use in the script can be download here http://www.mediafire.com/?7s341ckaxf7datc
>
>
> any idea for better png or other format image? (I need that each image in on a single file)
>
> PDF file seem to heavy to be open
>
> Regards
>
> Ugo
>
> script
>
> ;----------------------------------------------------------------------
> ; This example shows how to read geographic data
> ; from Natural Earth shapefiles
> ; and plot them as polylines and polygons.
> ;----------------------------------------------------------------------
> ; This particular example plots data for Switzerland.
> ;----------------------------------------------------------------------
> ; Download the shapefiles from http://www.naturalearthdata.com/
> ; Unzip to a directory
> ;----------------------------------------------------------------------
>
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/contrib/calendar_decode2.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/contrib/ut_string.ncl"
>
>
> ;****************************
> ; Funzioni personalizzate *
> ;****************************
>
> ; funzione Data validitÓ
>
> undef("Nuova_data")
> function Nuova_data(data:string)
> local anno, mese, giorno, ora, formato_data, data, data_intermedia_1, data_intermedia_2, data_intermedia_3, data_intermedia_4
>
> begin
>
> anno = stringtointeger( str_get_cols( data, 0, 3) )
> mese = stringtointeger( str_get_cols( data, 4, 5) )
> giorno = stringtointeger( str_get_cols( data, 6, 7) )
> ora = stringtointeger( str_get_cols( data, 8, 9) )
> formato_data = "hours since 1800-01-01 00:00:00"
>
> data_intermedia_1 = cd_inv_calendar( anno, mese, giorno, ora, 0, 0, formato_data, 0 )
>
> ; since data_intermedia_1 has the units "hours since ..." the 2 here adds 2 hours
> data_intermedia_2 = data_intermedia_1 + 2
> data_intermedia_2@units = formato_data
>
>
> data_intermedia_3 = cd_calendar( data_intermedia_2, -3 )
>
>
> data_intermedia_4 = sprinti ( "%0.8i", data_intermedia_3 )
>
> ymd2String=str_get_cols ( data_intermedia_4, 0, 7 )
> hr2String =str_get_cols ( data_intermedia_4, 8, 9 )
>
> data_intermedia_5 = systemfunc( "date -d '"+ymd2String+" "+hr2String+"' '+%A, %d/%m/%Y ore %H:00'" )
>
> if ((str_get_cols( data_intermedia_5, 0, 6) ).eq.("lunedý")) then
> nuova_data = "Lunedi~H-10V2F35~A~FV-2H3~"+ str_get_cols( data_intermedia_5, 7, strlen(data_intermedia_5)-1 )
> end if
> if ((str_get_cols( data_intermedia_5, 0, 7) ).eq.("martedý")) then
> nuova_data = "Martedi~H-10V2F35~A~FV-2H3~" + str_get_cols( data_intermedia_5, 8, strlen(data_intermedia_5)-1 )
> end if
> if ((str_get_cols( data_intermedia_5, 0, 9) ).eq.("mercoledý")) then
> nuova_data = "Mercoledi~H-10V2F35~A~FV-2H3~" + str_get_cols( data_intermedia_5, 10, strlen(data_intermedia_5)-1 )
> end if
> if ((str_get_cols( data_intermedia_5, 0, 7) ).eq.("giovedý")) then
> nuova_data = "Giovedi~H-10V2F35~A~FV-2H3~" + str_get_cols( data_intermedia_5, 8, strlen(data_intermedia_5)-1 )
> end if
> if ((str_get_cols( data_intermedia_5, 0, 7) ).eq.("venerdý")) then
> nuova_data = "Venerdi~H-10V2F35~A~FV-2H3~" + str_get_cols( data_intermedia_5, 8, strlen(data_intermedia_5)-1 )
> end if
> if ((str_get_cols( data_intermedia_5, 0, 5) ).eq.("sabato")) then
> nuova_data = "Sabato" + str_get_cols( data_intermedia_5, 6, strlen(data_intermedia_5)-1 )
> end if
> if ((str_get_cols( data_intermedia_5, 0, 7) ).eq.("domenica")) then
> nuova_data = "Domenica" + str_get_cols( data_intermedia_5, 8, strlen(data_intermedia_5)-1 )
> end if
>
>
> return (nuova_data)
>
> end
>
> ;**********************
> ; Codice principale *
> ;**********************
>
> begin
>
>
> ;*****************************************
> ; Open workstation and define colormap *
> ;*****************************************
>
> wks_type = "newpdf" ; use "newpdf" instead of "pdf" for smaller files
> wks_type@wkWidth = 1200
> wks_type@wkHeight = 1200
> wks = gsn_open_wks(wks_type,"File_temporaneo_precipitazioni")
> gsn_define_colormap(wks,"rainbow+white") ; choose colormap
>
>
>
>
>
>
> ;******************
> ; read gfs data *
> ;******************
>
> systemdate = systemfunc("date +%H%M")
>
> if ((systemdate.eq."0645"))then
> url = "http://nomads.ncep.noaa.gov:9090/dods/gfs_hd/gfs_hd" + systemfunc("date +%Y%m%d") + "/"
> filename = url + "gfs_hd_00z"
> run = "Run GFS 00 del " + systemfunc("date +%d/%m/%Y")
> run_nome_file = "Run_GFS_00Z"
> end if
> if ((systemdate.eq."1245")) then
> url = "http://nomads.ncep.noaa.gov:9090/dods/gfs_hd/gfs_hd" + systemfunc("date +%Y%m%d") + "/"
> filename = url + "gfs_hd_06z"
> run = "Run GFS 06 del " + systemfunc("date +%d/%m/%Y")
> run_nome_file = "Run_GFS_06Z"
> end if
> if ((systemdate.eq."1845")) then
> url = "http://nomads.ncep.noaa.gov:9090/dods/gfs_hd/gfs_hd" + systemfunc("date +%Y%m%d") + "/"
> filename = url + "gfs_hd_12z"
> run = "Run GFS 12 del " + systemfunc("date +%d/%m/%Y")
> run_nome_file = "Run_GFS_12Z"
> end if
> if ((systemdate.eq."0045")) then
> url = "http://nomads.ncep.noaa.gov:9090/dods/gfs_hd/gfs_hd" + systemfunc("date -d '-1 day' +'%Y%m%d'") + "/"
> filename = url + "gfs_hd_18z"
> run = "Run GFS 18 del " + systemfunc("date -d '-1 day' +'%d/%m/&Y'")
> run_nome_file = "Run_GFS_18Z"
> end if
>
> url = "http://nomads.ncep.noaa.gov:9090/dods/gfs_hd/gfs_hd20111019/"
> filename = url + "gfs_hd_12z"
> run = "Run GFS 00 del " + systemfunc("date +%d/%m/%Y")
> run_nome_file = "Run_GFS_12Z"
>
> exists = isfilepresent(filename)
> if(.not.exists) then
> print("OPeNDAP isfilepresent test unsuccessful.")
> print("Either file doesn't exist, or NCL does not have OPeNDAP capabilities on this system")
> else
> print("OPeNDAP isfilepresent test successful.")
> gfs = addfile(filename,"r")
> vars = getfilevarnames(gfs)
> end if
>
>
>
>
>
> ;*********************************
> ; risorse per la mappa di base *
> ;*********************************
> mappa = True ; plot mods desired
> mappa@mpProjection = "LambertConformal" ; choose projection
>
> mappa = True ; plot mods desired
>
> mappa@gsnMaximize = True
> mappa@gsnDraw = False ; do not draw the plot
> mappa@gsnFrame = False ; do not flip the page
>
> mappa@mpProjection = "LambertConformal" ; choose projection
> mappa@mpLimitMode = "LatLon"
> mappa@mpMaxLonF = 47.0
> mappa@mpMaxLatF = 88.5
> mappa@mpMinLatF = 27.0
> mappa@mpMinLonF = -43.0
> mappa@mpGridAndLimbOn = True ; turn on grid lines
> mappa@mpGridLineDashPattern = 10 ; lat/lon lines dashed
>
> ;******************************
> ; risorse generali dei plot *
> ;******************************
>
> plot_generale= True
> plot_generale@gsnMaximize = True
> plot_generale@gsnDraw = False ; do not draw the plot
> plot_generale@gsnFrame = False ; do not flip the page
> plot_generale@gsnAddCyclic = True
> plot_generale@gsnSpreadColors = False ; turn off the use entire color map
> plot_generale@gsnRightString = "" ; turn off right string
> plot_generale@gsnLeftString = ""
>
>
>
> ;*******************************
> ; risorse generali dei testi *
> ;*******************************
> testo_generale = True
> testo_generale@txFont = "times-roman" ; font
> testo_generale@txBackgroundFillColor = "Transparent"
>
>
> testo_titolo = testo_generale
> testo_titolo@txFontHeightF = 0.02 ; set the label size
> testo_titolo@txJust = "CenterLeft"
> testo_titolo@txPosXF = 0.02
> testo_titolo@txPosYF = 0.885
>
> testo_modello = testo_generale
> testo_modello@txFontHeightF = 0.015
> testo_modello@txJust = "BottomLeft"
> testo_modello@txPosXF = 0.02 ; Rough approximation
> testo_modello@txPosYF = 0.851
>
>
> testo_data = testo_generale
> testo_data@txFontHeightF = 0.015
> testo_data@txJust = "BottomRight"
> testo_data@txPosXF = 0.98 ; Rough approximation
> testo_data@txPosYF = 0.85
>
>
>
>
>
>
>
> drawNDCGrid(wks)
>
> ;******************************
> ; generazione mappa di base *
> ;******************************
>
> map = gsn_csm_map(wks,mappa)
>
> fnames = "/mnt/internetserver/map/shapefile/europa/aaa_full/" + (/"europa"/) + ".shp" ; Files to be open
> linecolors = (/"Black"/) ; color definition for each shapefile
> fillcolors = (/"Transparent"/) ; Fill color definition for each shapefile
> thicks = (/2/) ; Thickness for each shapefile
> lnres = True ; resources for polylines
> plres = True
> prims = True
> lines = True
> do n=0,dimsizes(fnames)-1 ; Loop through files that we want to read geographic information from.
> f = addfile(fnames(n),"r") ; Open the shapefile number n.
> segments = f->segments ; Read data off the shapefile
> geometry = f->geometry
> segsDims = dimsizes(segments)
> geomDims = dimsizes(geometry)
> geom_segIndex = f@geom_segIndex ; Read global attributes
> geom_numSegs = f@geom_numSegs
> segs_xyzIndex = f@segs_xyzIndex
> segs_numPnts = f@segs_numPnts
> geometry_type = f@geometry_type
> numFeatures = geomDims(0)
> lon = f->x
> lat = f->y
> if (geometry_type.eq."polygon") then ; Put if statement outside the loop
> plres@gsFillColor = fillcolors(n)
> plres@gsEdgesOn = True ; Draw border around polygons
> plres@gsEdgeColor = linecolors(n)
> plres@gsEdgeThicknessF = thicks(n)
> do i=0, numFeatures-1 ; Section to draw polygons on map.
> startSegment = geometry(i, geom_segIndex)
> numSegments = geometry(i, geom_numSegs)
> do seg=startSegment, startSegment+numSegments-1
> startPT = segments(seg, segs_xyzIndex)
> endPT = startPT + segments(seg, segs_numPnts) - 1
> dumstr = unique_string("lines") ; This call adds the polygon.
> map@$dumstr$ = gsn_add_polygon(wks, map , lon(startPT:endPT), lat(startPT:endPT), plres)
> end do
> end do
> else
> lnres@gsLineThicknessF = thicks(n)
> lnres@gsLineColor = linecolors(n)
> do i=0, numFeatures-1 ; Section to draw polylines on map.
> startSegment = geometry(i, geom_segIndex)
> numSegments = geometry(i, geom_numSegs)
> do seg=startSegment, startSegment+numSegments-1
> startPT = segments(seg, segs_xyzIndex)
> endPT = startPT + segments(seg, segs_numPnts) - 1
> dumstr = unique_string("primitive") ; This call adds the line segment.
> map@$dumstr$ = gsn_add_polyline(wks, map, lon(startPT:endPT), lat(startPT:endPT), lnres)
> end do
> end do
> end if
> delete(lat) ; Clean up before we read in same variables again.
> delete(lon)
> delete(segments)
> delete(geometry)
> delete(segsDims)
> delete(geomDims)
> end do
>
>
> ;******************
> ; Precipitazioni *
> ;******************
>
> ; Risorse
>
> precipitazioni = plot_generale
>
> precipitazioni@cnFillOn = True ; turn on color
> precipitazioni@cnLevelSelectionMode = "ExplicitLevels" ; set how manage contour line levels
> precipitazioni@cnLevels = (/0.00,0.01,0.02,0.03,0.04,0.05,0.06,0.07,0.08,0.09,0.10,0.20,0.30,0.40,0.50,0.60,0.70,0.80,0.90,1.00,1.50,2.00,2.50,3.00,3.50,4.00,4.50,5.00,5.50,6.00,6.50,7.00,7.50,8.00,8.50,9.00,9.50,10.00,10.50,11.00,11.50,12.00,12.50,13.00,13.50,14.00,14.50,15.00,16.00,17.00,18.00,19.00,20.00,21.00,22.00,23.00,24.00,25.00,30.00,35.00,40.00,45.00,50.00,55.00,60.00,65.00,70.00,75.00,80.00,85.00,90.00,95.00,100.00,105.00,110.00,115.00,120.00,125.00/)
> precipitazioni@cnFillColors = (/238,238,238,238,238,238,238,238,238,238,90,92,94,96,98,100,102,104,106,108,110,112,114,116,118,120,122,124,126,128,130,132,134,136,138,140,142,144,146,148,150,152,154,156,158,160,162,164,166,168,170,172,174,176,178,180,182,184,186,188,190,192,194,196,198,200,202,204,206,208,210,212,214,216,218,220,222,224/)
>
> precipitazioni@cnLinesOn = False ; turn on contour lines
> precipitazioni@cnLineLabelsOn = False ; turn on contour labels
>
>
>
> precipitazioni_convettive = plot_generale
>
> precipitazioni_convettive@cnFillOn = True ; turn off color
> precipitazioni_convettive@cnLevelSelectionMode = "ExplicitLevels" ; set how manage contour line levels
> precipitazioni_convettive@cnLevels = (/0.00,0.01,0.02,0.03,0.04,0.05,0.06,0.07,0.08,0.09,0.10,0.20,0.30,0.40,0.50,0.60,0.70,0.80,0.90,1.00,1.50,2.00,2.50,3.00,3.50,4.00,4.50,5.00,5.50,6.00,6.50,7.00,7.50,8.00,8.50,9.00,9.50,10.00,10.50,11.00,11.50,12.00,12.50,13.00,13.50,14.00,14.50,15.00,16.00,17.00,18.00,19.00,20.00,21.00,22.00,23.00,24.00,25.00,30.00,35.00,40.00,45.00,50.00,55.00,60.00,65.00,70.00,75.00,80.00,85.00,90.00,95.00,100.00,105.00,110.00,115.00,120.00,125.00/)
> precipitazioni_convettive@cnFillColors = (/238,238,238,238,238,238,238,238,238,238,90,92,94,96,98,100,102,104,106,108,110,112,114,116,118,120,122,124,126,128,130,132,134,136,138,140,142,144,146,148,150,152,154,156,158,160,162,164,166,168,170,172,174,176,178,180,182,184,186,188,190,192,194,196,198,200,202,204,206,208,210,212,214,216,218,220,222,224/)
>
> precipitazioni_convettive@cnLinesOn = True
> precipitazioni_convettive@cnLineLabelsOn = True ; turn on contour labels
> precipitazioni_convettive@cnMonoLineColor = True ; turn off auto contour line colors
> precipitazioni_convettive@cnLineColor = "Red"
>
> precipitazioni_convettive@cnMonoLineDashPattern = True
> precipitazioni_convettive@cnLineDashPattern = 11
> precipitazioni_convettive@cnLineDashSegLenF = 0.02
>
>
>
> precipitazioni_convettive@cnLevelFlags = (/"NoLine","NoLine","NoLine","NoLine","NoLine","NoLine","NoLine","NoLine","NoLine","NoLine", \
> "LineOnly","LineOnly","LineOnly","LineOnly","LineOnly","LineOnly","LineOnly","LineOnly","LineOnly","LineOnly", \
> "LineOnly","LineOnly","LineOnly","LineOnly","LineOnly","LineOnly","LineOnly","LineOnly","LineOnly","LineOnly", \
> "LineOnly","LineOnly","LineOnly","LineOnly","LineOnly","LineOnly","LineOnly","LineOnly","LineOnly","LineOnly", \
> "LineOnly","LineOnly","LineOnly","LineOnly","LineOnly","LineOnly","LineOnly","LineOnly","LineOnly","LineOnly", \
> "LineOnly","LineOnly","LineOnly","LineOnly","LineOnly","LineOnly","LineOnly","LineOnly","LineOnly"/) ; set how draw contour lines
>
> precipitazioni_convettive@lbLabelsOn = False
>
>
> ; precipitazioni_neve = plot_generale
> ; precipitazioni_neve@cnLinesOn = False ; turn on contour lines
> ; precipitazioni_neve@cnFillOn = True ; turn on color
> ; precipitazioni_neve@cnLevelSelectionMode = "ExplicitLevels" ; set how manage contour line levels
> ; precipitazioni_neve@cnLevels = (/0,1/)
> ; precipitazioni_neve@cnMonoLineDashPattern = False
> ; precipitazioni_neve@cnFillPatterns = (/0,17/)
> ; precipitazioni_neve@cnFillColors = (/-1,186/)
> ; precipitazioni_neve@lbLabelsOn = False
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> ;precipitazioni@lbAutoManage = False
> ;precipitazioni@lbLabelsOn = True ; turn on the labels
> ;precipitazioni@lbLabelAutoStride = True ; let NCL determine label spacing
> ;precipitazioni@lbLeftMarginF = 0.02
> ;precipitazioni@lbOrientation = "horizontal" ; label orientation
> ;precipitazioni@lbBoxLinesOn = True ; turn on lines between labelbar colors
> ;precipitazioni@lbLabelFont= "times-roman" ; font
> ;precipitazioni@lbLabelFontHeightF= 0.0045 ; set the label size
> ;precipitazioni@lbLabelAlignment = "BoxCenters"
> ;precipitazioni@pmLabelBarHeightF = 0.002
> ;precipitazioni@lbLabelStride = 5 ; label every other box
> ;precipitazioni@lbMonoFillColor = False
> ;precipitazioni@lbBoxCount = 148
> ;precipitazioni@lbBoxLinesOn = True
> ;precipitazioni@lbFillColors = (/90,90,90,90,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236/)
>
> ; Dati per plot
>
>
> PIOGGIA = gfs->cwatclm ; Rain
> ;PIOGGIA@_FillValue = 0.09999999
> PIOGGIA_CONVETTIVA = gfs->acpcpsfc ; Convective rain
> ;PIOGGIA_CONVETTIVA@_FillValue = 0.09999999
> ;NEVE = gfs->csnowsfc ;snow
> ;NEVE@_FillValue = 0.09999999
>
>
> NTIMES = dimsizes(gfs->time) ; number of times in the file
>
> do it = 0,1 ;NTIMES-1
> testo_titolo_plot = gsn_create_text(wks,"Precipitazioni accumultate nelle ultime 3 ore",testo_titolo)
> draw(testo_titolo_plot)
> testo_modello_plot = gsn_create_text(wks,(run),testo_modello)
> draw(testo_modello_plot)
> testo_data_plot = gsn_create_text(wks, (Nuova_data(ut_string(gfs->time(it),"%Y%N%D%H"))),testo_data)
> draw(testo_data_plot) ; Draw text box.
>
> precipitazioni_plot = gsn_csm_contour(wks,PIOGGIA(it,:,:),precipitazioni)
> overlay(map,precipitazioni_plot)
> draw(map)
> destroy(precipitazioni_plot)
>
> ;precipitazioni_convettive_plot = gsn_csm_contour(wks,PIOGGIA_CONVETTIVA(it,:,:),precipitazioni_convettive)
> ;overlay(map,precipitazioni_convettive_plot)
> ;draw(map)
> ;destroy(precipitazioni_convettive_plot)
>
>
> ;precipitazioni_neve_plot = gsn_csm_contour(wks,NEVE(it,:,:),precipitazioni_neve)
> ;overlay(map,precipitazioni_neve_plot)
> ;draw(map)
>
> frame(wks)
>
>
> end do
> do it = 0,1 ;NTIMES-1
> if (it.le.8) then
> system("mv File_temporaneo_precipitazioni.00000" + (it+1) + ".png" + " Precipitazioni0" + (it) + "_" + (run_nome_file) + ".png")
>
> end if
> if (it.eq.9) then
> system("mv File_temporaneo_precipitazioni.0000" + (it+1) + ".png" + " Precipitazioni0" + (it) + "_" + (run_nome_file) + ".png")
> end if
> if (it.ge.10) then
> system("mv File_temporaneo_precipitazioni.0000" + (it+1) + ".png" + " Precipitazioni" + (it) + "_" + (run_nome_file) + ".png")
> end if
> end do
>
> end
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu Oct 20 14:13:21 2011

This archive was generated by hypermail 2.1.8 : Mon Oct 24 2011 - 09:29:35 MDT