[ncl-talk] Station obs overlay on map

Debasish Hazra debasish.hazra5 at gmail.com
Thu Jul 30 22:01:34 MDT 2026


Thanks Dave for your suggestions. I included them and was able to generate
the figure. Only thing is that I would like to do an the station plot
overlay over model forecast and I am not sure how to do that. I am reading
in model data, but it does not overlay on the figure. Any suggestions is
appreciated.
Attached is revised code, output txt and generated figure.
Thanks,
Debasish


On Wed, Jul 29, 2026 at 10:25 AM Dave Allured - NOAA Affiliate <
dave.allured at noaa.gov> wrote:

> Debasish, you have this at the start of your program:
>
>      obs_lat = z->hdr_lat           ; indexed by nhdr
>      obs_lon = z->hdr_lon         ; indexed by nhdr
>      obs_hid = z->obs_hid        ; indexed by nobs
>
> However, the first two lines are not right.  You need obs coordinates
> indexed by the obs index, not the header index.  As you already said,
> "obs_hid" cross-references the obs index to the header index.  NCL  will
> conveniently cross-reference the coordinates by using vector subscripting.
>
>      hdr_lat = z->hdr_lat
>      hdr_lon = z->hdr_lon
>      obs_hid = z->obs_hid
>
>      obs_lat = (/ hdr_lat(obs_hid(:)) /)        ; now indexed by nobs
>      obs_lon = (/ hdr_lon(obs_hid(:)) /)       ; now indexed by nobs
>
> After this, use only the new obs_lat and obs_lon for station coordinates
> in the rest of the program.  The only other obs variables that you should
> need for plotting are obs_vid to select only the PM2.5 values, and obs_val
> for the actual data values.
>
>
> On Fri, Jul 24, 2026 at 10:29 PM Debasish Hazra <debasish.hazra5 at gmail.com>
> wrote:
>
>> Thanks Dave. Made some inroads related to the input file. As there can be
>> multiple variables stored for each station, that is why the number of
>> observations is larger. obs_var is the list of possible variables and
>> obs_vid is for the index of the obs_var for each observation value. There
>> is also the obs_hid, which lists the index of the header variables,
>> including lat/lon/etc for each observation. Attached is an input file, with
>> ncl program with more print statements to show obs_var, obs_vid and an
>> output txt file that shows print statements output.
>> So in this case, based on obs_vars, trying to read pm25 (2nd variable in
>> obs_vars), with corresponding obs_vids and obs_val and then group them in
>> selected bins to overlay on map. Any help on this is appreciated
>> Thanks,
>> Debasish
>>
>> On Mon, Jul 20, 2026 at 2:43 PM Dave Allured - NOAA Affiliate <
>> dave.allured at noaa.gov> wrote:
>>
>>> Debasish, the problem starts with the Airnow input file.  It has
>>> obs_lat and obs_lon on dimension nhdr, but pm25_data is on dimension nobs.
>>> These are two different sizes.  From the Airnow file, can you determine how
>>> to line up the coordinates for each of the 3982 obs values?  My guess is
>>> that there is some kind of cross referencing in the Airnow file, such as
>>> site ID arrays.
>>>
>>>
>>> On Mon, Jul 20, 2026 at 11:20 AM Debasish Hazra <
>>> debasish.hazra5 at gmail.com> wrote:
>>>
>>>> Thanks Dave, attached the revised ncl code with print statements you
>>>> have suggested along with print output and error in text message.
>>>>
>>>> On Mon, Jul 20, 2026 at 12:51 PM Dave Allured - NOAA Affiliate <
>>>> dave.allured at noaa.gov> wrote:
>>>>
>>>>> Debasish, please check your subscripting.  Immediately before the line
>>>>> that gets the error, add printVarSummary for lat_new, obs_lat, and
>>>>> "indexes".  Also include:
>>>>>
>>>>>     printMinMax (indexes, 0)
>>>>>     print ("num missing = " + num (ismissing (indexes)))
>>>>>     print (i)
>>>>>     print (npts_range)
>>>>>
>>>>> Show us all of this output immediately preceding the error, including
>>>>> the error message itself.  Do not show repeated outputs, only the last set
>>>>> of debug print messages before the error occurs.
>>>>>
>>>>>
>>>>> On Mon, Jul 20, 2026 at 8:05 AM Debasish Hazra via ncl-talk <
>>>>> ncl-talk at mailman.ucar.edu> wrote:
>>>>>
>>>>>> Thanks Karin for your reply. The file is big to attach, here is the
>>>>>> link of actual file :
>>>>>> https://nomads.ncep.noaa.gov/pub/data/nccf/com/gens/prod/gefs.20260718/00/chem/pgrb2ap25/
>>>>>> I am getting error in this line : lat_new(i,0:npts_range-1) =
>>>>>> obs_lat(indexes)
>>>>>> error says : fatal:Subscript out of range, error in subscript #0
>>>>>> fatal:["Execute.c":8637]:Execute: Error occurred at or near line 68
>>>>>> in file Test_read.ncl
>>>>>>
>>>>>> On Mon, Jul 20, 2026 at 3:17 AM Karin Meier-Fleischer <
>>>>>> meier-fleischer at dkrz.de> wrote:
>>>>>>
>>>>>>> Hi Debasish,
>>>>>>>
>>>>>>> the file gefs.chem.t00z.a2d_0p25.f018.grib2 is missing.
>>>>>>>
>>>>>>> Can you provide more Information about the error.
>>>>>>>
>>>>>>> Regards, Karin
>>>>>>>
>>>>>>> Am 18.07.26 um 04:26 schrieb Debasish Hazra via ncl-talk:
>>>>>>> > Hi,
>>>>>>> > I am trying to do a plot with station data in netcdf overlay on
>>>>>>> model
>>>>>>> > output following this example here
>>>>>>> > :https://www.ncl.ucar.edu/Applications/Scripts/polyg_8.ncl
>>>>>>> > But getting subscript range error. Attached is the ncl code and
>>>>>>> netcdf
>>>>>>> > station data used for this. Any help on this is greatly
>>>>>>> appreciated.
>>>>>>> >
>>>>>>> > Thanks
>>>>>>> > Debasish
>>>>>>
>>>>>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20260731/8daaffb2/attachment-0001.htm>
-------------- next part --------------
 Copyright (C) 1995-2019 - All Rights Reserved
 University Corporation for Atmospheric Research
 NCAR Command Language Version 6.6.2
 The use of this software is governed by a License Agreement.
 See http://www.ncl.ucar.edu/ for more details.

Variable: gsd1
Type: float
Total Size: 4152960 bytes
            1038240 values
Number of Dimensions: 2
Dimensions and sizes:	[lat_0 | 721] x [lon_0 | 1440]
Coordinates: 
            lat_0: [90..-90]
            lon_0: [ 0..359.75]
Number Of Attributes: 16
  center :	US National Weather Service - NCEP (WMC)
  production_status :	Operational products
  long_name :	Aerosol optical thickness
  units :	Numeric
  _FillValue :	1e+20
  grid_type :	Latitude/longitude
  parameter_discipline_and_category :	Meteorological products, Atmospheric chemical constituents
  parameter_template_discipline_category_number :	( 48, 0, 20, 102 )
  level_type :	Entire Atmosphere
  level :	 0
  forecast_time :	18
  forecast_time_units :	hours
  initial_time :	07/28/2026 (00:00)
  aerosol_wavelength :	>= 5.45e-07 and <= 5.65e-07
  aerosol_size :	< 2e-05
  aerosol_type :	Total Aerosol

Variable: gsd1
Type: float
Total Size: 4152960 bytes
            1038240 values
Number of Dimensions: 2
Dimensions and sizes:	[lat_0 | 721] x [lon_0 | 1440]
Coordinates: 
            lat_0: [-90..90]
            lon_0: [ 0..359.75]
Number Of Attributes: 16
  center :	US National Weather Service - NCEP (WMC)
  production_status :	Operational products
  long_name :	Aerosol optical thickness
  units :	Numeric
  _FillValue :	1e+20
  grid_type :	Latitude/longitude
  parameter_discipline_and_category :	Meteorological products, Atmospheric chemical constituents
  parameter_template_discipline_category_number :	( 48, 0, 20, 102 )
  level_type :	Entire Atmosphere
  level :	 0
  forecast_time :	18
  forecast_time_units :	hours
  initial_time :	07/28/2026 (00:00)
  aerosol_wavelength :	>= 5.45e-07 and <= 5.65e-07
  aerosol_size :	< 2e-05
  aerosol_type :	Total Aerosol

Variable: obsv_lat
Type: float
Total Size: 5240 bytes
            1310 values
Number of Dimensions: 1
Dimensions and sizes:	[1310]
Coordinates: 
Number Of Attributes: 1
  _FillValue :	-9999

Variable: obsv_lon
Type: float
Total Size: 5240 bytes
            1310 values
Number of Dimensions: 1
Dimensions and sizes:	[1310]
Coordinates: 
Number Of Attributes: 1
  _FillValue :	-9999

Variable: pm25_data
Type: float
Total Size: 15772 bytes
            3943 values
Number of Dimensions: 1
Dimensions and sizes:	[nobs | 3943]
Coordinates: 
Number Of Attributes: 2
  long_name :	observation value
  _FillValue :	-9999

Variable: data_pm
Type: float
Total Size: 5240 bytes
            1310 values
Number of Dimensions: 1
Dimensions and sizes:	[1310]
Coordinates: 
Number Of Attributes: 1
  _FillValue :	-9999

Variable: num_distinct_markers
Type: integer
Total Size: 4 bytes
            1 values
Number of Dimensions: 1
Dimensions and sizes:	[1]
Coordinates: 
(0)	min=0   max=1309
(0)	num missing = 0


Variable: i
Type: integer
Total Size: 4 bytes
            1 values
Number of Dimensions: 1
Dimensions and sizes:	[1]
Coordinates: 
(0)	0


Variable: npts_range
Type: integer
Total Size: 4 bytes
            1 values
Number of Dimensions: 1
Dimensions and sizes:	[1]
Coordinates: 
(0)	1301

Variable: lat_new
Type: float
Total Size: 62880 bytes
            15720 values
Number of Dimensions: 2
Dimensions and sizes:	[12] x [1310]
Coordinates: 
Number Of Attributes: 1
  _FillValue :	-9999

Variable: indexes
Type: integer
Total Size: 5204 bytes
            1301 values
Number of Dimensions: 1
Dimensions and sizes:	[1301]
Coordinates: 
(0)	min=9   max=1309
(0)	num missing = 0


Variable: i
Type: integer
Total Size: 4 bytes
            1 values
Number of Dimensions: 1
Dimensions and sizes:	[1]
Coordinates: 
(0)	1


Variable: npts_range
Type: integer
Total Size: 4 bytes
            1 values
Number of Dimensions: 1
Dimensions and sizes:	[1]
Coordinates: 
(0)	696

Variable: lat_new
Type: float
Total Size: 62880 bytes
            15720 values
Number of Dimensions: 2
Dimensions and sizes:	[12] x [1310]
Coordinates: 
Number Of Attributes: 1
  _FillValue :	-9999

Variable: indexes
Type: integer
Total Size: 2784 bytes
            696 values
Number of Dimensions: 1
Dimensions and sizes:	[696]
Coordinates: 
(0)	min=11   max=1306
(0)	num missing = 0


Variable: i
Type: integer
Total Size: 4 bytes
            1 values
Number of Dimensions: 1
Dimensions and sizes:	[1]
Coordinates: 
(0)	2


Variable: npts_range
Type: integer
Total Size: 4 bytes
            1 values
Number of Dimensions: 1
Dimensions and sizes:	[1]
Coordinates: 
(0)	266

Variable: lat_new
Type: float
Total Size: 62880 bytes
            15720 values
Number of Dimensions: 2
Dimensions and sizes:	[12] x [1310]
Coordinates: 
Number Of Attributes: 1
  _FillValue :	-9999

Variable: indexes
Type: integer
Total Size: 1064 bytes
            266 values
Number of Dimensions: 1
Dimensions and sizes:	[266]
Coordinates: 
(0)	min=71   max=1307
(0)	num missing = 0


Variable: i
Type: integer
Total Size: 4 bytes
            1 values
Number of Dimensions: 1
Dimensions and sizes:	[1]
Coordinates: 
(0)	3


Variable: npts_range
Type: integer
Total Size: 4 bytes
            1 values
Number of Dimensions: 1
Dimensions and sizes:	[1]
Coordinates: 
(0)	29

Variable: lat_new
Type: float
Total Size: 62880 bytes
            15720 values
Number of Dimensions: 2
Dimensions and sizes:	[12] x [1310]
Coordinates: 
Number Of Attributes: 1
  _FillValue :	-9999

Variable: indexes
Type: integer
Total Size: 116 bytes
            29 values
Number of Dimensions: 1
Dimensions and sizes:	[29]
Coordinates: 
(0)	min=95   max=1305
(0)	num missing = 0


Variable: i
Type: integer
Total Size: 4 bytes
            1 values
Number of Dimensions: 1
Dimensions and sizes:	[1]
Coordinates: 
(0)	4


Variable: npts_range
Type: integer
Total Size: 4 bytes
            1 values
Number of Dimensions: 1
Dimensions and sizes:	[1]
Coordinates: 
(0)	21

Variable: lat_new
Type: float
Total Size: 62880 bytes
            15720 values
Number of Dimensions: 2
Dimensions and sizes:	[12] x [1310]
Coordinates: 
Number Of Attributes: 1
  _FillValue :	-9999

Variable: indexes
Type: integer
Total Size: 84 bytes
            21 values
Number of Dimensions: 1
Dimensions and sizes:	[21]
Coordinates: 
(0)	min=677   max=1115
(0)	num missing = 0


Variable: i
Type: integer
Total Size: 4 bytes
            1 values
Number of Dimensions: 1
Dimensions and sizes:	[1]
Coordinates: 
(0)	5


Variable: npts_range
Type: integer
Total Size: 4 bytes
            1 values
Number of Dimensions: 1
Dimensions and sizes:	[1]
Coordinates: 
(0)	3

Variable: lat_new
Type: float
Total Size: 62880 bytes
            15720 values
Number of Dimensions: 2
Dimensions and sizes:	[12] x [1310]
Coordinates: 
Number Of Attributes: 1
  _FillValue :	-9999

Variable: indexes
Type: integer
Total Size: 12 bytes
            3 values
Number of Dimensions: 1
Dimensions and sizes:	[3]
Coordinates: 
(0)	min=81   max=734
(0)	num missing = 0


Variable: i
Type: integer
Total Size: 4 bytes
            1 values
Number of Dimensions: 1
Dimensions and sizes:	[1]
Coordinates: 
(0)	6


Variable: npts_range
Type: integer
Total Size: 4 bytes
            1 values
Number of Dimensions: 1
Dimensions and sizes:	[1]
Coordinates: 
(0)	4

Variable: lat_new
Type: float
Total Size: 62880 bytes
            15720 values
Number of Dimensions: 2
Dimensions and sizes:	[12] x [1310]
Coordinates: 
Number Of Attributes: 1
  _FillValue :	-9999

Variable: indexes
Type: integer
Total Size: 16 bytes
            4 values
Number of Dimensions: 1
Dimensions and sizes:	[4]
Coordinates: 
(0)	min=378   max=378
(0)	num missing = 0


Variable: i
Type: integer
Total Size: 4 bytes
            1 values
Number of Dimensions: 1
Dimensions and sizes:	[1]
Coordinates: 
(0)	7


Variable: npts_range
Type: integer
Total Size: 4 bytes
            1 values
Number of Dimensions: 1
Dimensions and sizes:	[1]
Coordinates: 
(0)	1

Variable: lat_new
Type: float
Total Size: 62880 bytes
            15720 values
Number of Dimensions: 2
Dimensions and sizes:	[12] x [1310]
Coordinates: 
Number Of Attributes: 1
  _FillValue :	-9999

Variable: indexes
Type: integer
Total Size: 4 bytes
            1 values
Number of Dimensions: 1
Dimensions and sizes:	[1]
Coordinates: 
(0)	min=759   max=1168
(0)	num missing = 0


Variable: i
Type: integer
Total Size: 4 bytes
            1 values
Number of Dimensions: 1
Dimensions and sizes:	[1]
Coordinates: 
(0)	8


Variable: npts_range
Type: integer
Total Size: 4 bytes
            1 values
Number of Dimensions: 1
Dimensions and sizes:	[1]
Coordinates: 
(0)	3

Variable: lat_new
Type: float
Total Size: 62880 bytes
            15720 values
Number of Dimensions: 2
Dimensions and sizes:	[12] x [1310]
Coordinates: 
Number Of Attributes: 1
  _FillValue :	-9999

Variable: indexes
Type: integer
Total Size: 12 bytes
            3 values
Number of Dimensions: 1
Dimensions and sizes:	[3]
Coordinates: 
(0)	min=758   max=758
(0)	num missing = 0


Variable: i
Type: integer
Total Size: 4 bytes
            1 values
Number of Dimensions: 1
Dimensions and sizes:	[1]
Coordinates: 
(0)	11


Variable: npts_range
Type: integer
Total Size: 4 bytes
            1 values
Number of Dimensions: 1
Dimensions and sizes:	[1]
Coordinates: 
(0)	1

Variable: lat_new
Type: float
Total Size: 62880 bytes
            15720 values
Number of Dimensions: 2
Dimensions and sizes:	[12] x [1310]
Coordinates: 
Number Of Attributes: 1
  _FillValue :	-9999

Variable: indexes
Type: integer
Total Size: 4 bytes
            1 values
Number of Dimensions: 1
Dimensions and sizes:	[1]
Coordinates: 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Test_read2.ncl
Type: application/octet-stream
Size: 7886 bytes
Desc: not available
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20260731/8daaffb2/attachment-0001.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Testfig_PM25_20260728_f018.png
Type: image/png
Size: 399384 bytes
Desc: not available
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20260731/8daaffb2/attachment-0001.png>


More information about the ncl-talk mailing list