Conversation
|
On commit 50b40ab50b40ab Including these dependencies in import astropy.coordinates |
|
I'll move these imports too, thanks for the headsup. As to where this method should live, |
|
FYI, this PR won't change |
5796e4c to
a17ab3b
Compare
arunkannawadi
left a comment
There was a problem hiding this comment.
I ran the hack.yaml in the save_asdf branch of roman_imsim_testdata and confirmed that it produces an ASDF file that can be read with roman_datamodels. Kudos on this great work Boyan, Navin and Raul 🎉
|
Requesting Axel and Sid to take a quick look as well - this could use more clean up, but I need to produce images in ASDF soon, so willing to cut corners as long as it works now. |
There was a problem hiding this comment.
I ran hack.yaml and things seem to look ok --
Python 3.14.3 | packaged by conda-forge | (main, Feb 9 2026, 21:56:02) [GCC 14.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import asdf
>>> import roman_datamodels as rdm
>>> dm = rdm.open("output/RomanWAS_new/images/truth/Roman_WAS_truth_J129_12909_4.asdf")
>>> dm.validate()And the corresponding image looks reasonable

A few changes/comments throughout. IMO, the use of create_fake_data is probably a blocker
| tree.meta.pointing.target_aperture = ( | ||
| f"{wcs_header['INSTRUME']}_CEN" # what kidn of aperture is wcs_header['RA_TARG'] | ||
| ) | ||
| tree.meta.pointing.target_ra = image.wcs.center.ra.deg # or wcs_header['RA_TARG']? |
There was a problem hiding this comment.
Is this still uncertain? (also below)
There was a problem hiding this comment.
Maybe something to check, usually "target" refer to where the telescope is pointing which can be the center of the mosaic but necessarily. image.wcs.center can refer to the center of the SCA or mosaic. It most cases they are not the same. The "target" coordinates should be provided by the observation sequence file.
Probably not a big if not set correctly for simulations though..
There was a problem hiding this comment.
meaning of meta.pointing.target_aperture:
title: Aperture Name Used for Pointing
description: Name of the aperture used to align the instrument to a position on the sky.
meaining of target_ra:
title: Right Ascension of the Target Aperture (deg)
description: Right ascension in units of degrees at the location of the target aperture.
I wasn't sure if one of these should go to pointing.target_ra: wcs_header["RA_TARG"] or image.wcs.header.header['CRVAL1'] or base['world_center'].ra.deg.
Also, please note that the origin differs between image and WCS pixel coordinates. And that creates some discrepancy between base['world_center'].ra.deg and image.wcs.header.header['CRVAL1'].
Please note the following -
# ==> But why is this value different? Is it expected?
ipdb> base['world_center'].ra.deg
10.832447108980707
# Versus
ipdb> image.wcs.header.header['CRVAL1']
np.float64(10.83242929473425)
----------------------------
ipdb> base['world_center'].dec.deg
-44.477474568888496
# Versus
ipdb> image.wcs.header.header['CRVAL2']
np.float64(-44.47749107477652)
----------------------------
# >>>>>>>>>>>> This is the issue
ipdb> for k in ['image_xsize', 'image_ysize', 'image_origin', 'image_center', 'image_bounds', 'wcs', 'world_center']:
print(k, "==>", base[k])
image_xsize ==> 4088
image_ysize ==> 4088
image_origin ==> galsim.PositionI(1,1)
image_center ==> galsim.PositionD(2044.5,2044.5)
image_bounds ==> galsim.BoundsI(1,4088,1,4088)
# Versus
ipdb> base['wcs'].origin
galsim.PositionD(x=0.0, y=0.0)
# Versus # comment = right ascension of the target (deg) (J2000)
ipdb> wcs_header["RA_TARG"]
10.566 There was a problem hiding this comment.
From what I see, I would recommend:
tree.meta.pointing.target_ra = wcs_header['RA_TARG']Now the difference between base['world_center'] and image.wcs.header.header['CRVAL1'] is 0.5 pixels. This is because the pixel center in the WCS is defined as: n_pix/2 which is 2044 while the base['world_center'] is defined with respect to the image center which is 2044.5
| tree.meta.ref_file.gain = tree.meta.ref_file.gain | ||
| # tree.meta.ref_file.inverselinearity = tree.meta.ref_file.inverselinearity | ||
| tree.meta.ref_file.linearity = tree.meta.ref_file.linearity | ||
| # tree.meta.ref_file.integralnonlinearity = tree.meta.ref_file.integralnonlinearity |
There was a problem hiding this comment.
I had to remove darkdecaysignal, inverselinearity and integralnonlinearity to make these work.
There was a problem hiding this comment.
I don't know what the problem was, since it was working fine for me. These are all default values, so I didn't care much when you commented it out.
Co-authored-by: Navin Chaurasiya <[email protected]> Co-authored-by: Raul Teixera <[email protected] .edu> Co-authored-by: Boyan Yin <[email protected]>
There was a problem hiding this comment.
I did a comparison between fits and asdf and I found some differences.
- First of all, the pixels are not the same and I don't understand why.. I used the same config file in the same environment I just saved to fits instead of asdf and I am not using
gzcompression. I found that 16% of the pixels are different with a mean difference of1.4e-10and a maximum difference of7e-4. - The WCS are also different. I think (hope) that it comes from the
+1in the NAXIS. right nowfits_wcs.pixel_to_world(100, 100) != asdf_wcs.pixel_to_world(100, 100)BUTfits_wcs.pixel_to_world(100, 100) == asdf_wcs.pixel_to_world(101, 101) - I really don't understand all the assignement of
tree.meta.SOMETHING = tree.meta.SOMETHING. Why are most of the keys assigned to themselves?
Edit: sorry for requesting changes afterward, I didn't found a way to update my review.. The +1 in NAXIS is a problem that need to be resolved before merge otherwise the wcs are mostlikely wrong.
Move header updates to sca.py
noise.py => added an optional key "ignore_noise". Not sure if leaving this one out was intentional? Please revert the changes if use of "ignore_noise" is supposed to be deprecated. sca.py => added a helpful comment telling to move a header card assignement to WCS file in the future output_asdf.py => cleanup
GWCS is by default 0-indexed. See https://gwcs.readthedocs.io/en/latest/gwcs/user_introduction.html The following inclusion of 0-indexing key in the yaml config file is necesasry to have 0-indexing in detector. image: index_convention: 0 Another minor change is to explicitly specify the type of image getting saved. => tree.meta.exposure.type = "WFI_IMAGE" This is to avoid deleting it along with all the default assignments by mistake.
| wcs_header.update(image.header) | ||
|
|
||
| tree = ImageModel.create_fake_data() | ||
|
|
There was a problem hiding this comment.
This function fills out default values for all of the fields that are adequate to make a valid file. You should only need to fill out new data in the tree that you have actually computed and where you care about the result. All of the lines that follow the pattern
tree.meta.product_type = tree.meta.product_type
are not doing anything and can be deleted---most of the mass of this function, lines 208 - 376 or so.
Re when using this is appropriate vs. not---the issue is that this is inventing a large amount of stuff---a large number of times, locations in orbits, investigator names, etc.. Conceptually the validation structure exists to make sure that this was all filled out correctly, and using create_fake_data(...) prevents that validation functionality from verifying that an attempt has been made to fill out all of the needed metadata. But for this code you likely do not want to be warned that you didn't enter a value for the status of the relative calibration system during this exposure, and indeed want some default garbage value and do not want to think more about this. That's what create_fake_data is for.
There was a problem hiding this comment.
Thanks for this context, Eddie -- this makes sense, I guess our use case isn't quite addressed by the cautions against using create_fake_data from the documentation (and or I misinterpreted)
This PR avails an option to save the output file in ASDF format that satisfies
roman_datamodels. This is a step towards migration from FITS to ASDF format. The changes include file format and metadata propagation to the output file. Further improvements can include assignment of specific values to the currently populated default-values (fromcreate_fake_data) for some keys in the metadata, and an implementation of the output file name consistent with WFI File Naming Conventions.