using pyresample to reproject grid

21 views
Skip to first unread message

אליקום ודיסלבסקי

unread,
Aug 29, 2023, 3:09:44 AM8/29/23
to pyt...@googlegroups.com

Dear counterparts,

 

Hope all is well.

 

I'm reading HSAF file and trying to reproject it to new grid using pyresample.

 

I'm getting the attached error message.

 

Maybe you have a solution.

 

Your help will be appreciated.

 

Elyakom Vadislavsky

IMS

 

 

My code:

 

# SEE domain

# lon : 4.05 to 45.25 by 0.1 degrees_east

# lat : 25.05 to 52.95 by 0.1 degrees_north

 

dx = dy = 0.1

 

lon_min = 4.05

lon_max = 45.25

lat_min = 25.05

lat_max = 52.95

 

# Area definitions for satpy resample

 

area_id = "SEE" # Identifier for the area

description = "South East Europe domain" # Human-readable description of the area

proj_id = "WGS84" # ID of projection

projection = CRS.from_epsg(4326) #, '+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs' # Dictionary or string with Proj.4 parameters

width = int((lon_max-lon_min)/dx+1) # x dimension in number of pixels, aka number of grid columns

height = int((lat_max-lat_min)/dy+1) # y dimension in number of pixels, aka number of grid rows

area_extent_ll = (lon_min,lat_min,lon_max,lat_max) # Area extent in lons lats as a tuple (lower_left_lon, lower_left_lat, upper_right_lon, upper_right_lat)

pixel_size_x = dx

pixel_size_y = dy

 

 

scn=Scene(reader='hsaf_grib', filenames=[grib])

print(scn.available_dataset_names())

scn.load(['h05B'])

my_area = AreaDefinition(area_id, description, proj_id, projection, width, height, area_extent_ll,pixel_size_x,pixel_size_y )

print(my_area)

local_scene = scn.resample(my_area)

 

 

 

error message:

 

File "/ims_home/vadislavskye/.local/lib/python3.9/site-packages/pyresample/geometry.py", line 2288, in get_proj_coords

    raise ValueError("'rotation' is not supported with dask operations.")

ValueError: 'rotation' is not supported with dask operations.

 

 

 

 

 

David Hoese

unread,
Aug 29, 2023, 10:01:43 AM8/29/23
to pyt...@googlegroups.com, אליקום ודיסלבסקי
Hi,

Your AreaDefinition creation has too many arguments. You are passing pixel_size_x and pixel_size_y which are not arguments accepted by `AreaDefinition`. It is taking those arguments and treating them like the (deprecated) "rotation" parameter. Please remove those last two arguments being passed to `AreaDefinition` and you should have better luck.

Dave
> --
> You received this message because you are subscribed to the Google Groups "pytroll" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to pytroll+u...@googlegroups.com <mailto:pytroll+u...@googlegroups.com>.
> To view this discussion on the web, visit https://groups.google.com/d/msgid/pytroll/6e6d8fcbbbf245689099d6709a4fb86e%40ims.gov.il <https://groups.google.com/d/msgid/pytroll/6e6d8fcbbbf245689099d6709a4fb86e%40ims.gov.il?utm_medium=email&utm_source=footer>.

אליקום ודיסלבסקי

unread,
Aug 30, 2023, 2:34:20 AM8/30/23
to Martin Raspaud, David Hoese, pyt...@googlegroups.com

Dear Dave and Martin,

 

Thank you very much for your fast response and major help.

 

I've followed your comments and managed to resample the HSAF grib to the target grid domain.

 

It went smoothly, really an elegant solution, applause to the PYTROLL team.

 

Also I've exported the data to NetCDF using satpy.

 

Attached image.

 

Best regards,

 

Elyakom

 

P.S

 

The inconsistency in the output image is sourced in the grib data and not due to the resampling process.

 

 

-----------------------------------------------------------------------------------------------------------------------------------

Martin Raspaud

unread,
Aug 30, 2023, 2:47:37 AM8/30/23
to pyt...@googlegroups.com
Dear Elyakom,

Very nice that it's now working for you!

Don't hesitate if you have more questions!

Best regards,
Martin

On 30/08/2023 08:34, אליקום ודיסלבסקי wrote:
> Dear Dave and Martin,
>
> Thank you very much for your fast response and major help.
>
> I've followed your comments and managed to resample the HSAF grib to the
> target grid domain.
>
> It went smoothly, really an elegant solution, applause to the PYTROLL team.
>
> Also I've exported the data to NetCDF using satpy.
>
> Attached image.
>
> Best regards,
>
> Elyakom
>
> P.S
>
> The inconsistency in the output image is sourced in the grib data and
> not due to the resampling process.
>
> -----------------------------------------------------------------------------------------------------------------------------------
>
> <mailto:pytroll+u...@googlegroups.com
> <mailto:pytroll+u...@googlegroups.com>>.
>
>> To view this discussion on the web, visit
> https://groups.google.com/d/msgid/pytroll/6e6d8fcbbbf245689099d6709a4fb86e%40ims.gov.il <https://groups.google.com/d/msgid/pytroll/6e6d8fcbbbf245689099d6709a4fb86e%40ims.gov.il> <https://groups.google.com/d/msgid/pytroll/6e6d8fcbbbf245689099d6709a4fb86e%40ims.gov.il?utm_medium=email&utm_source=footer <https://groups.google.com/d/msgid/pytroll/6e6d8fcbbbf245689099d6709a4fb86e%40ims.gov.il?utm_medium=email&utm_source=footer>>.
>
Reply all
Reply to author
Forward
0 new messages