Re: possible to set a _FillValue to a string for a numeric type var?

From: Dave Allured <dave.allured_at_nyahnyahspammersnyahnyah>
Date: Wed Feb 16 2011 - 18:46:24 MST

The use of missing values as function inputs in NCL is often not
well defined. The fill value trick may or may not work as you
expect. Use the ismissing and "where" functions for well defined
results in array situations like this.

http://www.ncl.ucar.edu/Document/Functions/Built-in/where.shtml

Prototype: where (condtnl_expr, true_value, false_value)

Change the last sprintf in your string expression to this (untested):

   where (ismissing(xTemp), "", sprintf("%10.3f ", xTemp))

By the way, you are defining a huge number of individual unique
strings in that array expression. NCL may become extremely slow
here due to internal string processing.

--Dave

On 2/16/2011 5:54 PM, donna Cote wrote:
> I have this part of my script which has 1D arrays, which are all the
> same size, for the Depth (dep3d_1d), Lon, Lat, and Temperature.
>
> This works to make strings (SQL inserts) of the data, but this includes
> any values of Temperature which are "ismissing". That _FillValue for
> Temperature is -99 (numeric) and I want it to be NULL (string? "" right?).
>
> Can I change the _FillValue like that?
> Maybe I should change the _FillValue to some outrageous value like
> -9999. It looks like I know how to do that. [ ;) ]
> Using -9999 will mean using a follow-up script which removes the -9999
> values from the strings. :(
>
> ncl 2> printVarSummary(xTemp)
>
>
> Variable: xTemp
> Type: float
> Total Size: 9210168 bytes
> 2302542 values
> Number of Dimensions: 3
> Dimensions and sizes: [Depth | 22] x [Latitude | 261] x [Longitude | 401]
> Coordinates:
> Depth: [ 0..3500]
> Latitude: [18..31]
> Longitude: [-98..-78]
> Number Of Attributes: 5
> Time : 252
> long_name : Potential Temperature
> units : deg C
> FORTRAN_format : f8.3
> _FillValue : -99
> ncl 3> xTemp@_FillValue=-9999
> ncl 4> printVarSummary(xTemp)
> <snip>
> _FillValue : -9999
> ncl 5>
>
> ;;;;;;;;;;;;;;;; snip of script:
> data = "INSERT INTO iasnowcast " \
> + "(datadatetime, depth, latitude, longitude, the_geog " \
> + ", temperature) VALUES ( "+newstring+", " \
> + sprintf("%7.16f " , dep3d_1d)+", " \
> + sprintf("%7.16f " , lon3d_1d)+", " \
> + sprintf("%7.16f " , lat3d_1d)+", ST_MakePoint(" \
> + sprintf("%7.16f " , lon3d_1d)+", " \
> + sprintf("%7.16f " , lat3d_1d)+", " \
> + sprintf("%7.16f " , dep3d_1d)+"), " \
> + sprintf("%10.3f ", xTemp)+" );"
>
>
>
> _______________________________________________
> 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 Wed Feb 16 18:46:29 2011

This archive was generated by hypermail 2.1.8 : Thu Feb 17 2011 - 22:00:17 MST