[ncl-talk] Replacement of data with a constant value

Herb, Jason jherb at albany.edu
Tue Jul 16 10:48:14 MDT 2019


Dennis,


I have been going thru the code trying to attempt to solve why the binned values for the for a given point plot between 0 and 110 based on the plot scale. This file that I am working with only has 4 swaths. Shouldn't the scale only go from 0 to 4  (if binning the total number of points with measured AOD values that have been replaced with 1 for valid data and 0 for invalid data) in that case given that the maximum number of times a given 1km x 1km point is sampled?


Thanks,

Jason

________________________________
From: Dennis Shea <shea at ucar.edu>
Sent: Monday, July 15, 2019 2:05:36 PM
To: Herb, Jason
Cc: ncl-talk at ucar.edu
Subject: Re: [ncl-talk] Replacement of data with a constant value

As noted in a previous ncl-talk question, the most important rule of data processing is "look at your data".
This is user responsibility.

+++ ON THE HDF FILE
      short Optical_Depth_047_grid1km ( Orbits_grid1km, YDim_grid1km, XDim_grid1km )
         coordinates :  GridLat_grid1km, GridLon_grid1km
         hdfeos_name :  Optical_Depth_047
         projection :   Sinusoidal
         valid_range :  ( -100, 5000 )    ; these pertain to the "short" numerical type
         _FillValue :   -28672                ; type "short"
         unit : none
         add_offset :      0
         scale_factor : 0.001
         long_name :    AOD at 0.47 micron

+++ AFTER unpacking via short2flt, the

Variable: x   <=== Optical_Depth_047_grid1km
Type: float
[SNIP]
  long_name : AOD at 0.47 micron
[snip]
  _FillValue : -28672              <== these are now type float
  valid_range : ( -0.1,  5 )     <== these are now type float in the unpacked range

Some code to add to your script.

 f0   = addfile(diri+fili(0)+".he2", "r")   ;  .he2 causes NCL to add lat/lon arrays
  x    = short2flt( f0->$vNam$   )   ; ( Orbits_grid1km, YDim_grid1km, XDim_grid1km )

printVarSummary(x)
printMinMax(x,0)
print("=============================")
  nmsg = num(ismissing(x))
  ngood= num(.not.ismissing(x))
  npts = nmsg+ngood
  npc  = (ngood/tofloat(npts))*100
print("nmsg ="+nmsg)
print("ngood="+ngood)
print("npc (%)="+npc)
print("=============================")

; *****************************************************************
  nx   = num(x.ge<http://x.ge>. -0.1 .and. x.le.5.0)   ; values after unpacking
                                          ; within allowed range
print("nx="+nx+":  this should match ngood="+ngood) ; ie: there are no out of range values
  X01  = where(x.ge<http://x.ge>. -0.1 .and. x.le.5.0, 1, 0)
printVarSummary(X01)
  n1n   = num(X01.eq.1)
  n1s   = sum(X01)
print("n1n="+n1n+"   n1s="+n1s)
print("=============================")

On Mon, Jul 15, 2019 at 10:27 AM Herb, Jason <jherb at albany.edu<mailto:jherb at albany.edu>> wrote:

Dennis,


I have attempted to make the suggested changes and received even more errors despite creating an additional variable..... errors can be found below below. I have attached full code and the file that I am working with to get the plot.


 Copyright (C) 1995-2017 - All Rights Reserved
 University Corporation for Atmospheric Research
 NCAR Command Language Version 6.4.0
 The use of this software is governed by a License Agreement.
 See http://www.ncl.ucar.edu/ for more details.
(0)     nfil=1
fatal:Number of dimensions on right hand side do not match number of dimension in left hand side
fatal:["Execute.c":8640]:Execute: Error occurred at or near line 106 in file MCD19A2.Jason2.ncl

fatal:syntax error: procedure bin_sum expects 7 arguments, got 8
fatal:error at line 128 in file MCD19A2.Jason2.ncl

fatal:Syntax Error in block, block not executed
fatal:error at line 133 in file MCD19A2.Jason2.ncl

(0)
=====> Wall Clock Elapsed Time: Main Sum Loop: nlat=3600, mlon=7200: 0 seconds <=====

fatal:Variable (f) is undefined
fatal:["Execute.c":8640]:Execute: Error occurred at or near line 151 in file MCD19A2.Jason2.ncl

fatal:Variable (f) is undefined
fatal:["Execute.c":8640]:Execute: Error occurred at or near line 157 in file MCD19A2.Jason2.ncl

fatal:syntax error: procedure gsn_panel expects 4 arguments, got 3
fatal:error at line 215 in file MCD19A2.Jason2.ncl

fatal:Syntax Error in block, block not executed
fatal:error at line 217 in file MCD19A2.Jason2.ncl



________________________________
From: Dennis Shea <shea at ucar.edu<mailto:shea at ucar.edu>>
Sent: Monday, July 15, 2019 11:18:35 AM
To: Herb, Jason
Cc: ncl-talk at ucar.edu<mailto:ncl-talk at ucar.edu>
Subject: Re: [ncl-talk] Replacement of data with a constant value

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

I am not sure where you got the form you are using for 'where'.
In no example is there an 'x=1' style for any of the arguments.

Also, given your description, I'm not sure that you want to use 'where'

x       = short2flt( f->$vNam$   )            ; ( Orbits_grid1km, YDim_grid1km, XDim_grid1km )
nx     = num(x.gt.-100 .and. x.lt.5000)   ; #  of values bwtweem -100 and 5000
===

x01   = where(x.gt.-100 .and. x.lt.5000, 0, 1)                  ; create an array of 0 and 1
n1     = num(x.eq.1)                              ; also: sum(x)

On Mon, Jul 15, 2019 at 8:24 AM Herb, Jason via ncl-talk <ncl-talk at ucar.edu<mailto:ncl-talk at ucar.edu>> wrote:

Hello,


I am working with the MCD19A2 data. In order to see the data extent for any given time period, 1 day, 1 month, 1 year, or any selected time period we need to assess.I have a binning code to add the points, however the points that are being added are the original AOD values in the hdf files. In order to do this I am attempting to replace all data points in the hdf file to " 1 " if there is data that is within the range flag of the data file. I have attempted to use the "where" function to make these replacements however I keep getting error bugs coming up. The portion of the script can be found below.


Script error messages

fatal:syntax error: line 120 in file MCD19A2.Jason1.ncl before or near =
     x1 = where(x.gt.-100 .and. x.lt.5000, x =
---------------------------------------------^

fatal:Syntax Error in block, block not executed
fatal:error at line 136 in file MCD19A2.Jason1.ncl

(0)
=====> Wall Clock Elapsed Time: Main Sum Loop: nlat=3600, mlon=7200: 0 seconds <=====

fatal:Variable (f) is undefined
fatal:["Execute.c":8640]:Execute: Error occurred at or near line 154 in file MCD19A2.Jason1.ncl

fatal:Variable (f) is undefined
fatal:["Execute.c":8640]:Execute: Error occurred at or near line 159 in file MCD19A2.Jason1.ncl

warning:ContourPlotInitialize: no valid values in scalar field; ContourPlot not possible:[errno=1101]
warning:ContourPlotInitialize: no valid values in scalar field; ContourPlot not possible:[errno=1101]


Script coding
 tStrt = systemfunc("date")         ; time the loop (wall clock)

  do nf=0,nfil-1                     ; loop over all files
     print(nf+"   "+fili(nf))
     f       = addfile(diri+fili(nf)+".he2", "r")   ;  .he2 causes NCL to add lat/lon arrays
                                     ; read data
     lat2d   = f->GridLat_grid1km
     lon2d   = f->GridLon_grid1km

     x       = short2flt( f->$vNam$   )   ; ( Orbits_grid1km, YDim_grid1km, XDim_grid1km )
;*************** attmeping to change any AOD data other then N/A to 1 to count up
     x1 = where(x.gt.-100 .and. x.lt.5000, x = 1)
     delete(  x  )
     x = x1

Thank you for you time

Jason


_______________________________________________
ncl-talk mailing list
ncl-talk at ucar.edu<mailto:ncl-talk at ucar.edu>
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20190716/3ea27cc1/attachment.html>


More information about the ncl-talk mailing list