-
Notifications
You must be signed in to change notification settings - Fork 7
Merge from asdf feature branch #95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
0Navin0
wants to merge
14
commits into
main
Choose a base branch
from
save_asdf
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
233d070
Sort deferred imports in skycat.py
arunkannawadi 2a40d0c
Add SCA to the FITS header
arunkannawadi f32ccbf
Add logs and comments to sca.py
arunkannawadi a03f8fe
Update dependencies in pyproject.toml
arunkannawadi 052c22d
Add ASDF output capability
arunkannawadi c91577f
Move header updates to sca.py
aguinot 6a990de
Merge pull request #97 from DukeCosmology/move_header
arunkannawadi e10555a
ammend comment typos
0Navin0 8eb632b
revert accidental changes
0Navin0 ec32532
add/remove comments, add missing opt key in sca
0Navin0 e026ca7
revert changes to noise.py
0Navin0 9172aba
Homogenise 0-indexing to detector image and GWCS
0Navin0 07233b8
fixup: roman datamodels version-based changes
arunkannawadi b145945
Add a standalone conversion script
arunkannawadi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,172 @@ | ||
| # Default settings for roman simulation | ||
| # Includes creation of noisless oversampled images (including PSF) | ||
| # -- processing of other detector and instrument effects are still handled in the | ||
| # python postprocessing layer to enable things not currently in galsim.roman | ||
|
|
||
| modules: | ||
|
|
||
| # Including galsim.roman in the list of modules to import will add a number of Roman-specific | ||
| # functions and classes that we will use here. | ||
| - roman_imsim | ||
| - galsim.roman | ||
|
|
||
| # We need this for one of our Eval items. GalSim does not by default import datetime into | ||
| # the globals dict it uses when evaluating Eval items, so we can tell it to import it here. | ||
| - datetime | ||
|
|
||
| # Define some other information about the images | ||
| image: | ||
|
|
||
| # A special Image type that knows all the Roman SCA geometry, WCS, gain, etc. | ||
| # It also by default applies a number of detector effects, but these can be turned | ||
| # off if desired by setting some parameters (given below) to False. | ||
| type: roman_sca | ||
|
|
||
| wcs: | ||
| type: RomanWCS | ||
| SCA: '@image.SCA' | ||
| ra: { type: ObSeqData, field: ra } | ||
| dec: { type: ObSeqData, field: dec } | ||
| pa: { type: ObSeqData, field: pa } | ||
| mjd: { type: ObSeqData, field: mjd } | ||
|
|
||
| index_convention: 0 | ||
|
|
||
| bandpass: | ||
| type: RomanBandpass | ||
| name: { type: ObSeqData, field: filter } | ||
|
|
||
| # When you want to have multiple images generate the same random galaxies, then | ||
| # you can set up multiple random number generators with different update cadences | ||
| # by making random_seed a list. | ||
| # The default behavior is just to have the random seeds for each object go in order by | ||
| # object number across all images, but this shows how to set it up so we use two separate | ||
| # cadences. | ||
| # The first one behaves normally, which will be used for things like noise on the image. | ||
| # The second one sets the initial seed for each object to repeat to the same starting value | ||
| # at the start of each filter. If we were doing more than 3 total files, it would then | ||
| # move on to another sequence for the next 3 and so on. | ||
| random_seed: | ||
| # Used for noise and nobjects. | ||
| - { type: ObSeqData, field: visit } | ||
|
|
||
| # Used for objects. Repeats sequence for each filter | ||
| # Note: Don't use $ shorthand here, since that will implicitly be evaluated once and then | ||
| # treated the same way as an integer (i.e. making a regular sequence starting from that | ||
| # value). Using an explicit dict with an Eval type means GalSim will leave it alone and | ||
| # evaluate it as is for each object. | ||
|
|
||
|
|
||
| # We're just doing one SCA here. | ||
| # If you wanted to do all of them in each of three filters (given below), you could use: | ||
| # | ||
| # SCA: | ||
| # type: Sequence | ||
| # first: 1 | ||
| # last: 18 | ||
| # repeat: 3 # repeat each SCA num 3 times before moving on, for the 3 filters. | ||
| # | ||
| SCA: 5 | ||
| mjd: { type: ObSeqData, field: mjd } | ||
| filter: { type: ObSeqData, field: filter } | ||
| exptime: { type: ObSeqData, field: exptime } | ||
|
|
||
| draw_method: 'phot' | ||
| # Photon shooting is way faster for chromatic objects than fft, especially when most of them | ||
| # are fairly faint. The cross-over point for achromatic objects is generally of order | ||
| # flux=1.e6 or so (depending on the profile). Most of our objects here are much fainter than | ||
| # that. The fft rendering for chromatic is a factor of 10 or so slower still, whereas | ||
| # chromatic photon shooting is only slighly slower than achromatic, so the difference | ||
| # is even more pronounced in this case. | ||
| use_fft_bright: True | ||
|
|
||
| noise: | ||
| # # These are all by default turned on, but you can turn any of them off if desired: | ||
| # type: RomanNoise | ||
| # stray_light: True | ||
| # thermal_background: True | ||
| # reciprocity_failure: True | ||
| # dark_current: True | ||
| # nonlinearity: True | ||
| # ipc: True | ||
| # read_noise: True | ||
| # sky_subtract: False | ||
|
|
||
| type: NoNoise | ||
|
|
||
| index_convention: 0 | ||
| nobjects: 10 | ||
|
|
||
| stamp: | ||
| type: Roman_stamp | ||
| world_pos: | ||
| type: SkyCatWorldPos | ||
| exptime: { type: ObSeqData, field: exptime } | ||
| skip_failures: True | ||
| photon_ops: | ||
| - | ||
| type: ChargeDiff | ||
|
|
||
| # psf: | ||
| # type: roman_psf | ||
| # # If omitted, it would figure this out automatically, because we are using the RomanSCA image | ||
| # # type. But if we weren't, you'd have to tell it which SCA to build the PSF for. | ||
| # SCA: '@image.SCA' | ||
| # # n_waves defines how finely to sample the PSF profile over the bandpass. | ||
| # # Using 10 wavelengths usually gives decent accuracy. | ||
| # n_waves: 10 | ||
|
|
||
| # Define the galaxy type and positions to use | ||
| gal: | ||
| type: SkyCatObj | ||
|
|
||
| input: | ||
| obseq_data: | ||
| file_name: Roman_WAS_obseq_11_1_23.fits | ||
| visit: 12909 | ||
| SCA: '@image.SCA' | ||
| roman_psf: | ||
| SCA: '@image.SCA' | ||
| n_waves: 5 | ||
| sky_catalog: | ||
| file_name: skyCatalog//skyCatalog.yaml | ||
| edge_pix: 512 | ||
| mjd: { type: ObSeqData, field: mjd } | ||
| exptime: { type: ObSeqData, field: exptime } | ||
| obj_types: ['diffsky_galaxy','star','snana'] | ||
|
|
||
| output: | ||
|
|
||
| #type: Fits | ||
| type: RomanASDF | ||
| nfiles: 1 | ||
| dir: output/RomanWAS_new/images/truth | ||
| include_raw_header: true | ||
| file_name: | ||
| type: FormattedStr | ||
| #format: "Roman_WAS_truth_%s_%i_%i.fits.gz" | ||
| format: "Roman_WAS_truth_%s_%i_%i.asdf" | ||
| items: | ||
| - { type: ObSeqData, field: filter } | ||
| - { type: ObSeqData, field: visit } | ||
| - '@image.SCA' | ||
|
|
||
| truth: | ||
| dir: output/RomanWAS_new/truth | ||
| file_name: | ||
| type: FormattedStr | ||
| format: "Roman_WAS_index_%s_%i_%i.txt" | ||
| items: | ||
| - { type: ObSeqData, field: filter } | ||
| - { type: ObSeqData, field: visit } | ||
| - '@image.SCA' | ||
| columns: | ||
| object_id: "@object_id" | ||
| ra: "$sky_pos.ra.deg" | ||
| dec: "$sky_pos.dec.deg" | ||
| x: "$image_pos.x" | ||
| y: "$image_pos.y" | ||
| realized_flux: "@realized_flux" | ||
| flux: "@flux" | ||
| mag: "@mag" | ||
| obj_type: "@object_type" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| """Standalone script to convert existing FITS file to ASDF. | ||
| """ | ||
| import galsim | ||
| import os | ||
| from roman_imsim.output_asdf import RomanASDFBuilder | ||
| import logging | ||
|
|
||
| logger = logging.getLogger() | ||
|
|
||
| builder = RomanASDFBuilder() | ||
| builder.include_raw_header = False | ||
|
|
||
| dir_path = "/hpc/group/cosmology/ajk107/code/roman_imsim/RomanTDS_prism/images/simple_model" | ||
| names = os.listdir(dir_path) | ||
| for name in names: | ||
| if name.endswith(".fits.gz"): | ||
| fname_path = os.path.join(dir_path, name) | ||
| visit = int(name.split("_")[-2]) | ||
| base = {"input": {"obseq_data": {"visit": visit}}} | ||
| config = {} | ||
| im = galsim.fits.read(fname_path, hdu=1, read_header=True) | ||
| im.header["FILTER"] = "PRISM" | ||
|
|
||
| builder._writeASDF(config, base, im, fname_path.replace(".fits.gz", ".asdf"), logger) | ||
| logger.info(f"Converted {name}") | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.