Re: Grabbing ECMWF ensemble values for a station (37.6200, -122.4000)

From: David Brown <dbrown_at_nyahnyahspammersnyahnyah>
Date: Wed, 27 May 2009 16:40:13 -0600

On May 27, 2009, at 2:16 PM, satish viswanatham wrote:

> I installed it and looks like there is new dimension called
> ensemble0 and also 2 new varibales 'ensemble0_info' and 'ensemble0'.
>
> I am not too familiar with the PyNIO API yet? How to get hold of
>
> print f.variables['TP_GDS0_SFC'].shape
> print f.variables['TP_GDS0_SFC_1'].shape
>
> That tells me that TP_GDS0_SFC has
> (51, 49, 53) --> 2597 ensemble sets
>
> That tells me that TP_GDS0_SFC_1 has
> (51, 71, 141) --> 10011 ensemble sets
>
> Basically this file contains around 13K points and each having
> ensemble sets?
>
> To find precip for 37.6200,-122.400. will be lon4 and lat1 close to
> 37 and -122. Would it be TP_GDS0_SFC or TP_GDS0_SFC_1.
>

If you look at the print of the file, you can see that TP_GDS0_SFC
has dimensions [ ensemble0, g0_lat_1, g0_lon_2 ], whereas
TP_GDS0_SFC_1 has dimensions [ ensemble0, g0_lat_3, g0_lon_4 ].
g0_lat_1 and g0_lon_2 form one lat/lon grid and g0_lat_3 and g0_lon_4
form another lat/on grid. The point you want lat 37, lon -122 appears
on only one of these grids -- the one formed by g0_lat_3 and
g0_lon_4. That means you must get your data from TP_GDS0_SFC_1.
To get all 51 elements of the ensemble dimension at 37.62 latitude
and -122.4 longitude can be done most easily using PyNIO extended
subscripting:

import Nio

f = Nio.open_file("W1E_20090526_0000_20090526_0000_1.grb")
v = f.variables['TP_GDS0_SFC_1']
data = v[': 37.6200 -122.4000']
print(data)

This returns the data for the grid point closest to the specified
coordinates: lat 37.5 and lon -122.5. If you want the data to be
interpolated for the exact coordinate then you would add the letter
'i' as a suffix after each coordinate value:

data = v[': 37.6200i -122.4000i']
print(data)

You could (if you wanted to for some reason) chose the nearest
coordinate in latitude but interpolate in longitude or vice versa by
omitting the 'i' suffix from one or the other value.

Unfortunately the data file you sent contains all 0.0 values for the
TP_GDS0_SFC_1 variable so it is hard to demonstrate the behavior in a
useful way.

The only variable in this file besides the coordinate values that has
non-zero values are the geopotential variables: Z_GDS0_SFC and
Z_GDS0_SFC_1. These variables do not have the ensemble dimension.
Therefore there is only a single value at a specified coordinate for
these variables. But the idea is the same:

v = f.variables['Z_GDS0_SFC_1']
data = v['37.6200 -122.4000']
print(data)
data = v['37.6200i -122.4000i']
print(data)
data = v['37.6200 -122.4000i']
print(data)
data = v['37.6200i -122.4000']
print(data)

outputs:

1227.33520508
1266.40320508 #bi-linear interpolation
1359.83520508 #linear interpolation in longitude only
1167.81520508 #linear interpolation in latitude only

The values over which this interpolation takes place are:

print(v['38:37.5 -122.5:-122'])
[[ 979.33520508 935.33520508]
  [ 1227.33520508 1889.83520508]]

same as (in index space -- normal NumPy subscripting):

print(v[44:46,25:27])

[[ 979.33520508 935.33520508]
  [ 1227.33520508 1889.83520508]]

Hope this helps.
  -dave

> Thank you for your help.
>
> Thanks
> Satish
>
> lon 2
> [-11. -10.5 -10. -9.5 -9. -8.5 -8. -7.5 -7. -6.5 -6.
> -5.5
> -5. -4.5 -4. -3.5 -3. -2.5 -2. -1.5 -1. -0.5
> 0. 0.5
> 1. 1.5 2. 2.5 3. 3.5 4. 4.5 5. 5.5
> 6. 6.5
> 7. 7.5 8. 8.5 9. 9.5 10. 10.5 11. 11.5 12.
> 12.5
> 13. 13.5 14. 14.5 15. ]
> lon 4
> [-135. -134.5 -134. -133.5 -133. -132.5 -132. -131.5 -131. -130.5
> -130. -129.5 -129. -128.5 -128. -127.5 -127. -126.5 -126. -125.5
> -125. -124.5 -124. -123.5 -123. -122.5 -122. -121.5 -121. -120.5
> -120. -119.5 -119. -118.5 -118. -117.5 -117. -116.5 -116. -115.5
> -115. -114.5 -114. -113.5 -113. -112.5 -112. -111.5 -111. -110.5
> -110. -109.5 -109. -108.5 -108. -107.5 -107. -106.5 -106. -105.5
> -105. -104.5 -104. -103.5 -103. -102.5 -102. -101.5 -101. -100.5
> -100. -99.5 -99. -98.5 -98. -97.5 -97. -96.5 -96. -95.5
> -95. -94.5 -94. -93.5 -93. -92.5 -92. -91.5 -91. -90.5
> -90. -89.5 -89. -88.5 -88. -87.5 -87. -86.5 -86. -85.5
> -85. -84.5 -84. -83.5 -83. -82.5 -82. -81.5 -81. -80.5
> -80. -79.5 -79. -78.5 -78. -77.5 -77. -76.5 -76. -75.5
> -75. -74.5 -74. -73.5 -73. -72.5 -72. -71.5 -71. -70.5
> -70. -69.5 -69. -68.5 -68. -67.5 -67. -66.5 -66. -65.5
> -65. ]
> lat 1
> [ 36. 36.5 37. 37.5 38. 38.5 39. 39.5 40. 40.5 41.
> 41.5
> 42. 42.5 43. 43.5 44. 44.5 45. 45.5 46. 46.5 47.
> 47.5
> 48. 48.5 49. 49.5 50. 50.5 51. 51.5 52. 52.5 53.
> 53.5
> 54. 54.5 55. 55.5 56. 56.5 57. 57.5 58. 58.5 59.
> 59.5
> 60. ]
> lat 3
> [ 60. 59.5 59. 58.5 58. 57.5 57. 56.5 56. 55.5 55.
> 54.5
> 54. 53.5 53. 52.5 52. 51.5 51. 50.5 50. 49.5 49.
> 48.5
> 48. 47.5 47. 46.5 46. 45.5 45. 44.5 44. 43.5 43.
> 42.5
> 42. 41.5 41. 40.5 40. 39.5 39. 38.5 38. 37.5 37.
> 36.5
> 36. 35.5 35. 34.5 34. 33.5 33. 32.5 32. 31.5 31.
> 30.5
> 30. 29.5 29. 28.5 28. 27.5 27. 26.5 26. 25.5 25. ]
>
>
> Nio file: /export/disk0/grb-files/
> W1E_20090526_0000_20090530_1200_1.grb2
> global attributes:
> dimensions:
> ensemble0 = 51
> g0_lat_1 = 49
> g0_lon_2 = 53
> g0_lat_3 = 71
> g0_lon_4 = 141
> variables:
> float VAR_121_GDS0_SFC [ ensemble0, g0_lat_1, g0_lon_2 ]
> center : European Center for Medium-Range Weather
> Forecasts (RSMC)
> long_name : Unknown Variable Name
> units : unknown
> _FillValue : 1e+20
> level_indicator : 1
> gds_grid_type : 0
> parameter_table_version : 128
> parameter_number : 121
> forecast_time : 108
> forecast_time_units : hours
> initial_time : 05/26/2009 (00:00)
> float VAR_121_GDS0_SFC_1 [ ensemble0, g0_lat_3, g0_lon_4 ]
> center : European Center for Medium-Range Weather
> Forecasts (RSMC)
> long_name : Unknown Variable Name
> units : unknown
> _FillValue : 1e+20
> level_indicator : 1
> gds_grid_type : 0
> parameter_table_version : 128
> parameter_number : 121
> forecast_time : 108
> forecast_time_units : hours
> initial_time : 05/26/2009 (00:00)
> float VAR_122_GDS0_SFC [ ensemble0, g0_lat_1, g0_lon_2 ]
> center : European Center for Medium-Range Weather
> Forecasts (RSMC)
> long_name : Unknown Variable Name
> units : unknown
> _FillValue : 1e+20
> level_indicator : 1
> gds_grid_type : 0
> parameter_table_version : 128
> parameter_number : 122
> forecast_time : 108
> forecast_time_units : hours
> initial_time : 05/26/2009 (00:00)
> float VAR_122_GDS0_SFC_1 [ ensemble0, g0_lat_3, g0_lon_4 ]
> center : European Center for Medium-Range Weather
> Forecasts (RSMC)
> long_name : Unknown Variable Name
> units : unknown
> _FillValue : 1e+20
> level_indicator : 1
> gds_grid_type : 0
> parameter_table_version : 128
> parameter_number : 122
> forecast_time : 108
> forecast_time_units : hours
> initial_time : 05/26/2009 (00:00)
> float TP_GDS0_SFC [ ensemble0, g0_lat_1, g0_lon_2 ]
> center : European Center for Medium-Range Weather
> Forecasts (RSMC)
> long_name : Total precipitation
> units : m
> _FillValue : 1e+20
> level_indicator : 1
> gds_grid_type : 0
> parameter_table_version : 128
> parameter_number : 228
> forecast_time : 108
> forecast_time_units : hours
> initial_time : 05/26/2009 (00:00)
> float TP_GDS0_SFC_1 [ ensemble0, g0_lat_3, g0_lon_4 ]
> center : European Center for Medium-Range Weather
> Forecasts (RSMC)
> long_name : Total precipitation
> units : m
> _FillValue : 1e+20
> level_indicator : 1
> gds_grid_type : 0
> parameter_table_version : 128
> parameter_number : 228
> forecast_time : 108
> forecast_time_units : hours
> initial_time : 05/26/2009 (00:00)
> float g0_lat_3 [ g0_lat_3 ]
> long_name : latitude
> GridType : Cylindrical Equidistant Projection Grid
> units : degrees_north
> Dj : 0.5
> Di : 0.5
> Lo2 : -65
> La2 : 25
> Lo1 : -135
> La1 : 60
> float g0_lon_4 [ g0_lon_4 ]
> long_name : longitude
> GridType : Cylindrical Equidistant Projection Grid
> units : degrees_east
> Dj : 0.5
> Di : 0.5
> Lo2 : -65
> La2 : 25
> Lo1 : -135
> La1 : 60
> float g0_lat_1 [ g0_lat_1 ]
> long_name : latitude
> GridType : Cylindrical Equidistant Projection Grid
> units : degrees_north
> Dj : 0.5
> Di : 0.5
> Lo2 : 15
> La2 : 36
> Lo1 : -11
> La1 : 60
> float g0_lon_2 [ g0_lon_2 ]
> long_name : longitude
> GridType : Cylindrical Equidistant Projection Grid
> units : degrees_east
> Dj : 0.5
> Di : 0.5
> Lo2 : 15
> La2 : 36
> Lo1 : -11
> La1 : 60
> string ensemble0_info [ ensemble0 ]
> long_name : ensemble elements description
> integer ensemble0 [ ensemble0 ]
> long_name : ensemble indexes
> units : non-dim
>
>

_______________________________________________
pyngl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/pyngl-talk
Received on Wed May 27 2009 - 16:40:13 MDT

This archive was generated by hypermail 2.2.0 : Mon Jun 01 2009 - 07:48:18 MDT