LSSTDESC / imSim

GalSim based Rubin Observatory image simulation package
https://lsstdesc.org/imSim
BSD 3-Clause "New" or "Revised" License
36 stars 15 forks source link

Add ability to add keywords for the DM Butler directly into primary amp headers. #443

Closed jbkalmbach closed 10 months ago

jbkalmbach commented 10 months ago

I primarily wanted to get the PROGRAM header into the amp files to specify a science_program in the butler repository for the data but I think it was cleaner to make something that can accommodate any other optional headers that might be useful in the future.

jmeyers314 commented 10 months ago

I can't remember, does GetAllParams apply config processing within the dict? For example, can you do?:

output:
  readout:
    added_keywords:
      some_math: $1+2

If so, that'd be a nice test.

jbkalmbach commented 10 months ago

I can't remember, does GetAllParams apply config processing within the dict? For example, can you do?:

output:
  readout:
    added_keywords:
      some_math: $1+2

If so, that'd be a nice test.

No, it doesn't look like the way I did it processes the math. Is there a better function to use?

jmeyers314 commented 10 months ago

I think something like the following should work:

        # Parse parameters from the config dict.
        opt = {
            'camera': str,
            'readout_time': float,
            'dark_current': float,
            'bias_level': float,
            'scti': float,
            'pcti': float,
            'full_well': float,
            'read_noise': float,
            'bias_levels_file': str,
            }
        ignore = ['file_name', 'dir', 'hdu', 'filter', 'added_keywords']
        kwargs = GetAllParams(config, base, opt=opt, ignore=ignore)[0]

        if 'added_keywords' in config:
            kwargs['added_keywords'] = {}
            for k in (added_keywords := config.get('added_keywords', {})):
                kwargs['added_keywords'][k], safe = ParseValue(added_keywords, k, base, str)
jbkalmbach commented 10 months ago

Thanks! Yeah, that did the trick.

jbkalmbach commented 10 months ago

@jmeyers314 I think this is ready for a review if you have a chance.

jbkalmbach commented 10 months ago

Thanks! Unfortunately I don't have write access on the repo so if you could merge it that would be great!