Large negative indices returned by ll_to_xy

109 views
Skip to first unread message

Tim Raupach

unread,
May 14, 2020, 10:28:08 PM5/14/20
to wrfpyth...@ucar.edu
Hi wrfpython-talk,

I noticed something odd when using wrf.ll_to_xy with a rotated lat/long domain, where longitude values at or greater than -1*pole_lon produce a large negative x index. When the meridian at -1*pole_lon degrees is crossed, the returned west-east index goes from the expected value x to (x - n), where n is the number of pixels in the circumference of the Earth.

The same behaviour occurs with wrf.ll_to_xy_proj when I manually specify the projection, and the same results are given by the NCL versions of the functions. xy_to_ll works as expected for the same projection. Can anyone explain the result? Is it a bug, or rather due to a badly-defined projection or rotation? A reproducible example is below.

Thanks,
Tim

import wrf

## x, y to lat, long works fine.
wrf
.xy_to_ll_proj(x=203, y=100, map_proj=6, stand_lon=-8,
                  ref_lat
=43.912167, ref_lon=4.119123, pole_lat=43.2,
                  pole_lon
=180, known_x=0, known_y=0, dx=1528.68,
                  dy
=1528.68)

wrf
.xy_to_ll_proj(x=204, y=100, map_proj=6, stand_lon=-8,
                  ref_lat
=43.912167, ref_lon=4.119123, pole_lat=43.2,
                  pole_lon
=180, known_x=0, known_y=0, dx=1528.68,
                  dy
=1528.68)

## x=203, y=100 gives latitude=45.35623931, longitude=7.99014617
## x=204, y=100 gives latitude=45.35623932, longitude=8.0097073

## lat, long to x, y produces longitude that is correct until
## longitude >= -1*stand_lon.

wrf
.ll_to_xy_proj(latitude=45.35623931, longitude=7.99014617,
                  map_proj
=6, stand_lon=-8, ref_lat=43.912167,
                  ref_lon
=4.119123, pole_lat=43.2, pole_lon=180,
                  known_x
=0, known_y=0, dx=1528.68, dy=1528.68)

wrf
.ll_to_xy_proj(latitude=45.35623932, longitude=8.0097073,
                  map_proj
=6, stand_lon=-8, ref_lat=43.912167,
                  ref_lon
=4.119123, pole_lat=43.2, pole_lon=180,
                  known_x
=0, known_y=0, dx=1528.68, dy=1528.68)

## latitude=45.35623931, longitude=7.99014617 gives x=203, y=100
## latitude=45.35623932, longitude=8.0097073 gives x=-25978, y=100

## The amount by which the x value is wrong is 204--25978 = 26182,
## which is the number of dx-sized pixels in the Earth's
## circumference:

dx
= 1528.68
np
.round((2*wrf.Constants.WRF_EARTH_RADIUS*wrf.Constants.PI)/dx,0)
## Returns 26182.0.



Reply all
Reply to author
Forward
0 new messages