Skip to content

Commit 3022876

Browse files
authored
Update wcs interface to use pixel_to_world_values instead of non-values versions. (#195)
* Update wcs interface to use world_to_pixel_values instead of non-values versions. * Pass world_to_pixel, numerical_inverse arrays rather than astropy table columns.
1 parent ec38b29 commit 3022876

File tree

5 files changed

+13
-11
lines changed

5 files changed

+13
-11
lines changed

romanisim/image.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -964,8 +964,8 @@ def inject_sources_into_l2(model, cat, x=None, y=None, psf=None, rng=None,
964964
rng = galsim.UniformDeviate(123)
965965

966966
if x is None or y is None:
967-
x, y = model.meta.wcs.numerical_inverse(cat['ra'], cat['dec'],
968-
with_bounding_box=False)
967+
x, y = model.meta.wcs.numerical_inverse(
968+
cat['ra'].value, cat['dec'].value, with_bounding_box=False)
969969

970970
filter_name = model.meta.instrument.optical_element
971971
cat = catalog.table_to_catalog(cat, [filter_name])

romanisim/l3.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ def inject_sources_into_l3(model, cat, x=None, y=None, psf=None, rng=None,
142142
rng = galsim.UniformDeviate(seed)
143143

144144
if x is None or y is None:
145-
x, y = model.meta.wcs.numerical_inverse(cat['ra'], cat['dec'],
145+
x, y = model.meta.wcs.numerical_inverse(cat['ra'].value, cat['dec'].value,
146146
with_bounding_box=False)
147147

148148
filter_name = model.meta.basic.optical_element
@@ -756,7 +756,7 @@ def add_more_metadata(metadata, efftimes, filter_name, wcs, shape, nexposures):
756756
metadata['resample']['pointings'] = nexposures
757757
metadata['resample']['product_exposure_time'] = (
758758
metadata['basic']['max_exposure_time'])
759-
xref, yref = wcs.world_to_pixel(
759+
xref, yref = wcs.world_to_pixel_values(
760760
metadata['wcsinfo']['ra_ref'], metadata['wcsinfo']['dec_ref'])
761761
metadata['wcsinfo']['x_ref'] = xref
762762
metadata['wcsinfo']['y_ref'] = yref

romanisim/tests/test_l3.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ def test_sim_mosaic():
161161

162162
# Create bounds from the object list
163163
twcs = romanisim.wcs.get_mosaic_wcs(metadata)
164-
allx, ally = twcs.world_to_pixel(cat['ra'], cat['dec'])
164+
allx, ally = twcs.world_to_pixel_values(cat['ra'].value, cat['dec'].value)
165165

166166
# Obtain the sample extremums
167167
xmin = min(allx)
@@ -170,7 +170,7 @@ def test_sim_mosaic():
170170
ymax = max(ally)
171171

172172
# Obtain WCS center
173-
xcen, ycen = twcs.world_to_pixel(ra_ref, dec_ref)
173+
xcen, ycen = twcs.world_to_pixel_values(ra_ref, dec_ref)
174174

175175
# Determine maximum extremums from WCS center
176176
xdiff = max([math.ceil(xmax - xcen), math.ceil(xcen - xmin)]) + 1
@@ -191,7 +191,8 @@ def test_sim_mosaic():
191191
assert len(extras['objinfo']) == len(cat)
192192

193193
# Ensure center pixel of bright objects is bright
194-
x_all, y_all = moswcs.world_to_pixel(cat['ra'][:10], cat['dec'][:10])
194+
x_all, y_all = moswcs.world_to_pixel_values(cat['ra'][:10].value,
195+
cat['dec'][:10].value)
195196
for x, y in zip(x_all, y_all):
196197
x = int(x)
197198
y = int(y)
@@ -581,7 +582,7 @@ def test_scaling():
581582
# pixel scales are different by a factor of two.
582583
fluxes = []
583584
for im, fac in zip((im1, im2, im3), (1, 2, 1)):
584-
pix = im.meta.wcs.world_to_pixel(
585+
pix = im.meta.wcs.world_to_pixel_values(
585586
imdict['tabcatalog']['ra'][0], imdict['tabcatalog']['dec'][0])
586587
pind = [int(x) for x in pix]
587588
margin = 30 * fac

romanisim/util.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -516,8 +516,9 @@ def update_photom_keywords(im, gain=None):
516516
if 'wcs' in im['meta']:
517517
wcs = im['meta']['wcs']
518518
cenpix = (im.data.shape[0] // 2, im.data.shape[1] // 2)
519-
cc = wcs.pixel_to_world((cenpix[0], cenpix[0], cenpix[0] + 1),
520-
(cenpix[1], cenpix[1] + 1, cenpix[1]))
519+
cc = wcs.pixel_to_world(
520+
(cenpix[0], cenpix[0], cenpix[0] + 1),
521+
(cenpix[1], cenpix[1] + 1, cenpix[1]))
521522
angle = (cc[0].position_angle(cc[1]) -
522523
cc[0].position_angle(cc[2]))
523524
area = (cc[0].separation(cc[1]) * cc[0].separation(cc[2])

romanisim/wcs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ def coeffs_to_poly(mat, degree):
374374
# convention in the galsim CelestialWCS object, we delete that here.
375375
# Success is defined by
376376
# (GWCS._radec(x, y) ==
377-
# wcs_from_fits_header(GWCS.header.header).pixel_to_world(x, y))
377+
# wcs_from_fits_header(GWCS.header.header).pixel_to_world_values(x, y))
378378

379379
cd = w.wcs.piximg_matrix
380380

0 commit comments

Comments
 (0)