コード例 #1
0
def data_path(jail):
    """Create data file with needed header parameters"""
    model = ImageModel()

    model.meta.target.ra = 90.75541666666666
    model.meta.target.dec = -66.56055555555554
    model.meta.pointing.ra_v1 = 91.08142004561715
    model.meta.pointing.dec_v1 = -66.60547868904696
    model.meta.wcsinfo.ra_ref = 90.70377653291781
    model.meta.wcsinfo.dec_ref = -66.59540223936895

    model.save('data.fits')
    return model.meta.filename
コード例 #2
0
def test_open_kwargs_asdf(tmp_path):
    """
    Test that unrecognized kwargs to the datamodels.open function
    are passed on to the model class constructor.
    """
    file_path = tmp_path / "test.asdf"

    with pytest.warns(ValidationWarning):
        model = ImageModel((4, 4), pass_invalid_values=True)
        model.meta.instrument.name = "CELESTRON"
        model.save(file_path)

    with pytest.raises(ValidationError):
        with datamodels.open(file_path, strict_validation=True) as model:
            model.validate()
コード例 #3
0
def test_open_kwargs_fits(tmp_path):
    """
    Test that unrecognized kwargs to the datamodels.open function
    are passed on to the model class constructor.  Similar to the
    above, except the invalid file must be created differently
    because DataModel can't save an invalid .fits file.
    """
    file_path = tmp_path / "test.fits"

    model = ImageModel((4, 4))
    model.save(file_path)

    with fits.open(file_path, mode="update") as hdul:
        hdul[0].header["INSTRUME"] = "CELESTRON"
        hdul.flush()

    with pytest.raises(ValidationError):
        with datamodels.open(file_path, strict_validation=True) as model:
            model.validate()
コード例 #4
0
im.dq = hdul_rate['DQ'].data
im.var_poisson = hdul_rate['VAR_POISSON'].data
im.var_rnoise = hdul_rate['VAR_RNOISE'].data

im.meta.target.proper_motion_epoch = "2000"
im.meta.dither.primary_type = "IMAGING"

ra_ref = header_slp['RA_REF']
dec_ref = header_slp['DEC_REF']
crval1_ra = header_slp['CRVAL1']
crval2_dec = header_slp['CRVAL2']
targ_ra = header_slp['TARG_RA']
targ_dec = header_slp['TARG_DEC']

c_ref = SkyCoord(ra=ra_ref * u.degree, dec=dec_ref * u.degree, frame='fk5')
c_crval = SkyCoord(ra=crval1_ra * u.degree,
                   dec=crval2_dec * u.degree,
                   frame='fk5')
c_targ = SkyCoord(ra=targ_ra * u.degree, dec=targ_dec * u.degree, frame='fk5')
header_slp['RA_REF'] = c_ref.icrs.ra.degree
header_slp['DEC_REF'] = c_ref.icrs.dec.degree
header_slp['CRVAL1'] = c_crval.icrs.ra.degree
header_slp['CRVAL2'] = c_crval.icrs.dec.degree
header_slp['TARG_RA'] = c_targ.icrs.ra.degree
header_slp['TARG_DEC'] = c_targ.icrs.dec.degree
header_slp['RADESYS'] = 'ICRS'
im.meta.coordinates.reference_frame = 'ICRS'
im.meta.telescope = 'JWST'
im.meta.naxis = 2
im.save('test_im_rate.fits')