Skip to content

Instantly share code, notes, and snippets.

View jdavies-st's full-sized avatar

James Davies jdavies-st

  • Max Planck Institute for Astronomy
  • Heidelberg, Germany
  • 15:30 (UTC +02:00)
View GitHub Profile
@jdavies-st
jdavies-st / __init__.py
Last active March 6, 2023 08:47
pyspextool instrument-based read_fits
from . import extract
from .setup_utils import pyspextool_setup, set_paths, set_instrument
# Is there a reason for absolute imports below and relative imports above?
from pyspextool.instrument_data.spex_dir.spex import read_fits as _read_fits_spex
from pyspextool.instrument_data.uspex_dir.uspex import read_fits as _read_fits_uspex
instrument = None
class CompoundConverter(TransformConverter):
_tags_add = {
"http://asdf-format.org/schemas/transform/add-2.0.0",
"tag:stsci.edu:asdf/transform/add-1.2.0",
"tag:stsci.edu:asdf/transform/add-1.1.0",
"tag:stsci.edu:asdf/transform/add-1.0.0",
}
_tags_subtract = {
"http://asdf-format.org/schemas/transform/subtract-2.0.0",
"tag:stsci.edu:asdf/transform/subtract-1.2.0",
@jdavies-st
jdavies-st / ast_to_gwcs.py
Last active June 30, 2020 14:52
Representing forked WCS trees in ASDF using GWCS
# This is to show how one might represent two linear WCS pipelines that share a step in ASDF using GWCS
# The transform comes from JWST NIRCam imaging.
from jwst import datamodels
import asdf
from copy import deepcopy
# Use some existing NIRCam Imaging data which has a GWCS object in it
@jdavies-st
jdavies-st / modeling_to_asdf.py
Last active October 29, 2019 21:37
serialize astropy.modeling instance to ASDF
>>> from astropy.modeling import models, fitting
>>> import asdf
>>> import numpy as np
>>> x = np.random.random(100)
>>> y = np.random.random(100)
>>>
>>> mymodel = models.Polynomial1D(degree=3)
>>> fitter = fitting.LevMarLSQFitter()
>>> myfit = fitter(mymodel,x,y)
WARNING: Model is linear in parameters; consider using linear fitting methods. [astropy.modeling.fitting]