Last active
September 19, 2018 20:02
-
-
Save drdavella/5f4b7c4831cd099e72353effeb2e42f7 to your computer and use it in GitHub Desktop.
Add custom step to WCS pipeline and serialize with ASDF
This file contains 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
#!/usr/bin/env python | |
import os | |
import sys | |
import copy | |
import asdf | |
from astropy import modeling | |
class IdentityTrans(modeling.Fittable2DModel): | |
inputs = ('x', 'y') | |
outputs = ('x1', 'y1') | |
p = modeling.Parameter(default=1) | |
@staticmethod | |
def evaluate(x, y, p): | |
return x, y | |
def process(filename): | |
af = asdf.open(filename) | |
wcs = copy.deepcopy(af['meta']['wcs']) | |
wcs.insert_transform('world', IdentityTrans(p=2)) | |
af['meta']['wcs'] = wcs | |
return af | |
def main(): | |
if len(sys.argv) != 2: | |
script = os.path.basename(sys.argv[0]) | |
sys.stderr.write(f'USAGE: {script} <filename>\n') | |
sys.exit(1) | |
new_af = process(sys.argv[1]) | |
new_af.write_to('new.asdf') | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment