当前位置: 首页>>代码示例>>Python>>正文


Python asdf.AsdfFile类代码示例

本文整理汇总了Python中asdf.AsdfFile的典型用法代码示例。如果您正苦于以下问题:Python AsdfFile类的具体用法?Python AsdfFile怎么用?Python AsdfFile使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了AsdfFile类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: ifu_msa_to_oteip

def ifu_msa_to_oteip(reference_files):
    """
    Transform from the MSA frame to the OTEIP frame.

    Parameters
    ----------
    reference_files: dict
        Dictionary with reference files returned by CRDS.

    Returns
    -------
    model : `~astropy.modeling.core.Model` model.
        Transform from MSA to OTEIP.
    """
    with AsdfFile.open(reference_files['fore']) as f:
        fore = f.tree['model'].copy()
    with AsdfFile.open(reference_files['ifufore']) as f:
        ifufore = f.tree['model'].copy()

    msa2fore_mapping = Mapping((0, 1, 2, 2))
    msa2fore_mapping.inverse = Identity(3)
    ifu_fore_transform = ifufore & Identity(1)
    ifu_fore_transform.inverse = Mapping((0, 1, 2, 2)) | ifufore.inverse & Identity(1)
    fore_transform = msa2fore_mapping | fore & Identity(1)
    return msa2fore_mapping | ifu_fore_transform | fore_transform
开发者ID:philhodge,项目名称:jwst,代码行数:25,代码来源:nirspec.py

示例2: _check_value

def _check_value(value, schema):
    """
    Perform the actual validation.
    """
    if value is None:
        if schema.get('fits_required'):
            name = schema.get("fits_keyword") or schema.get("fits_hdu")
            raise jsonschema.ValidationError("%s is a required value"
                                              % name)
    else:
        validator_context = AsdfFile()
        validator_resolver = validator_context.resolver

        temp_schema = {
            '$schema':
            'http://stsci.edu/schemas/asdf-schema/0.1.0/asdf-schema'}
        temp_schema.update(schema)
        validator = asdf_schema.get_validator(temp_schema,
                                              validator_context,
                                              validator_callbacks,
                                              validator_resolver)

        value = yamlutil.custom_tree_to_tagged_tree(value, validator_context)
        validator.validate(value, _schema=temp_schema)
        validator_context.close()
开发者ID:STScI-JWST,项目名称:jwst,代码行数:25,代码来源:validate.py

示例3: alpha_beta2XanYan

def alpha_beta2XanYan(input_model, reference_files):
    """
    Create the transform from detector to Xan, Yan frame.

    forward transform:
      RegionsSelector
        label_mapper is LabelMapperDict()
        {channel_wave_range (): channel_number}
        selector is {channel_number: ab2Xan & ab2Yan}
    bacward_transform
      RegionsSelector
        label_mapper is LabelMapperDict()
        {channel_wave_range (): channel_number}
        selector is {channel_number: Xan2ab & Yan2ab}
    """
    band = input_model.meta.instrument.band
    channel = input_model.meta.instrument.channel
    # used to read the wavelength range
    channels = [c + band for c in channel]

    f = AsdfFile.open(reference_files['v2v3'])
    v23 = f.tree['model']
    f.close()
    f = AsdfFile.open(reference_files['wavelengthrange'])
    # the following should go in the asdf reader
    wave_range = f.tree['wavelengthrange'].copy()
    wave_channels = f.tree['channels']
    wr = {}
    for ch, r in zip(wave_channels, wave_range):
        wr[ch] = r
    f.close()

    dict_mapper = {}
    sel = {}
    for c in channels:
        ch = int(c[0])
        dict_mapper[tuple(wr[c])] = models.Mapping((2,), name="mapping_lam") | \
                   models.Const1D(ch, name="channel #")
        map1 = models.Mapping((1, 0, 1, 0), name='map2poly')
        map1._outputs = ('alpha', 'beta', 'alpha', 'beta')
        map1._inputs = ('alpha', 'beta')
        map1.inverse = models.Mapping((0, 1))
        ident1 = models.Identity(1, name='identity_lam')
        ident1._inputs = ('lam',)
        chan_v23 = v23[c]
        v23chan_backward = chan_v23.inverse
        del chan_v23.inverse
        v23_spatial = map1 | chan_v23
        v23_spatial.inverse = map1 | v23chan_backward
        v23c = v23_spatial & ident1
        sel[ch] = v23c

    wave_range_mapper = selector.LabelMapperRange(('alpha', 'beta', 'lam'), dict_mapper,
                                                  inputs_mapping=models.Mapping([2,]))
    wave_range_mapper.inverse = wave_range_mapper.copy()
    ab2xyan = selector.RegionsSelector(('alpha', 'beta', 'lam'), ('v2', 'v3', 'lam'),
                                      label_mapper=wave_range_mapper,
                                      selector=sel)

    return ab2xyan
开发者ID:nden,项目名称:jwst,代码行数:60,代码来源:miri.py

示例4: imaging_distortion

def imaging_distortion(input_model, reference_files):
    """
    Create pixe2sky and sky2pixel transformation for the MIRI imager.

    Parameters
    ----------
    model : jwst_lib.models.ImagingModel
        input model
    reference_files : dict
        reference files from CRDS


    using CDP 3 Reference distortion file
    MIRI_FM_MIRIMAGE_F1000W_PSF_03.01.00.fits

    reference files/corrections needed (pixel to sky):

    1. Filter dependent shift in (x,y) (!with an oposite sign to that delievred by the IT)
    2. Apply MI
    3. Apply Ai and BI matrices
    4. Apply the TI matrix (this gives V2/V3 coordinates)
    5. Apply V2/V3 to sky transformation

    ref_file: filter_offset.asdf - (1)
    ref_file: distortion.asdf -(2,3,4)
    """
    distortion = AsdfFile.open(reference_files['distortion']).tree['model']
    filter_offset = AsdfFile.open(reference_files['filteroffset']).tree[input_model.meta.instrument.filter]
    full_distortion = models.Shift(filter_offset['row_offset']) & models.Shift(
        filter_offset['column_offset']) | distortion
    full_distortion = full_distortion.rename('distortion')
    return full_distortion
开发者ID:nden,项目名称:jwst,代码行数:32,代码来源:miri.py

示例5: saveto_asdf

    def saveto_asdf(self, path, header=None, update_path=True):

        """
        This function ...
        :param path:
        :param header:
        :param update_path:
        :return:
        """

        # If a header is not specified, created it from the WCS
        if header is None: header = self.header

        # Import
        from asdf import AsdfFile

        # Create the tree
        tree = dict()

        tree["data"] = self._data
        tree["header"] = header

        # Create the asdf file
        ff = AsdfFile(tree)

        # Write
        ff.write_to(path)

        # Update the path
        if update_path: self.path = path
开发者ID:SKIRT,项目名称:PTS,代码行数:30,代码来源:mask.py

示例6: test_backwards_compat_gcrs

def test_backwards_compat_gcrs():
    obsgeoloc = (
        3.0856775814671916e+16,
        9.257032744401574e+16,
        6.1713551629343834e+19
    )
    obsgeovel = (2.0, 1.0, 8.0)

    old_frame_yaml =  """
frames:
  - !wcs/celestial_frame-1.0.0
    axes_names: [lon, lat]
    name: CelestialFrame
    reference_frame:
      type: GCRS
      obsgeoloc:
        - [%f, %f, %f]
        - !unit/unit-1.0.0 m
      obsgeovel:
        - [%f, %f, %f]
        - !unit/unit-1.0.0 m s-1
      obstime: !time/time-1.0.0 2010-01-01 00:00:00.000
    unit: [!unit/unit-1.0.0 deg, !unit/unit-1.0.0 deg]
""" % (obsgeovel + obsgeoloc)

    new_frame_yaml = """
frames:
  - !wcs/celestial_frame-1.1.0
    axes_names: [lon, lat]
    name: CelestialFrame
    reference_frame:
      type: GCRS
      obsgeoloc:
      - !unit/quantity-1.1.0 {unit: !unit/unit-1.0.0 m, value: %f}
      - !unit/quantity-1.1.0 {unit: !unit/unit-1.0.0 m, value: %f}
      - !unit/quantity-1.1.0 {unit: !unit/unit-1.0.0 m, value: %f}
      obsgeovel:
      - !unit/quantity-1.1.0 {unit: !unit/unit-1.0.0 m s-1, value: %f}
      - !unit/quantity-1.1.0 {unit: !unit/unit-1.0.0 m s-1, value: %f}
      - !unit/quantity-1.1.0 {unit: !unit/unit-1.0.0 m s-1, value: %f}
      obstime: !time/time-1.1.0 2010-01-01 00:00:00.000
    unit: [!unit/unit-1.0.0 deg, !unit/unit-1.0.0 deg]
""" % (obsgeovel + obsgeoloc)

    old_buff = helpers.yaml_to_asdf(old_frame_yaml)
    old_asdf = AsdfFile.open(old_buff)
    old_frame = old_asdf.tree['frames'][0]
    old_loc = old_frame.reference_frame.obsgeoloc
    old_vel = old_frame.reference_frame.obsgeovel

    new_buff = helpers.yaml_to_asdf(new_frame_yaml)
    new_asdf = AsdfFile.open(new_buff)
    new_frame = new_asdf.tree['frames'][0]
    new_loc = new_frame.reference_frame.obsgeoloc
    new_vel = new_frame.reference_frame.obsgeovel

    assert (old_loc.x == new_loc.x and old_loc.y == new_loc.y and
        old_loc.z == new_loc.z)
    assert (old_vel.x == new_vel.x and old_vel.y == new_vel.y and
        old_vel.z == new_vel.z)
开发者ID:vmarkovtsev,项目名称:asdf,代码行数:60,代码来源:test_wcs.py

示例7: ifupost2asdf

def ifupost2asdf(ifupost_files, outname):
    """
    Create a reference file of type ``ifupost`` .

    Combines all IDT ``IFU-POST`` reference files in one ASDF file.

    forward direction : MSA to Collimator
    backward_direction: Collimator to MSA

    Parameters
    ----------
    ifupost_files : list
        Names of all ``IFU-POST`` IDT reference files
    outname : str
        Name of output ``ASDF`` file
    """
    ref_kw = common_reference_file_keywords("IFUPOST", "NIRSPEC IFU-POST transforms - CDP4")
    fa = AsdfFile()
    fa.tree = ref_kw
    for fifu in ifupost_files:
        n = int((fifu.split('IFU-POST_')[1]).split('.pcf')[0])
        fa.tree[n] = {}
        with open(fifu) as f:
            lines = [l.strip() for l in f.readlines()]
        factors = lines[lines.index('*Factor 2') + 1].split()
        rotation_angle = float(lines[lines.index('*Rotation') + 1])
        input_rot_center = lines[lines.index('*InputRotationCentre 2') + 1].split()
        output_rot_center = lines[lines.index('*OutputRotationCentre 2') + 1].split()
        linear_sky2det = homothetic_sky2det(input_rot_center, rotation_angle, factors, output_rot_center)

        degree = int(lines[lines.index('*FitOrder') + 1])

        xcoeff_index = lines.index('*xForwardCoefficients 21 2')
        xlines = lines[xcoeff_index + 1: xcoeff_index + 22]
        xcoeff_forward = coeffs_from_pcf(degree, xlines)
        x_poly_forward = models.Polynomial2D(degree, name='x_poly_forward', **xcoeff_forward)

        ycoeff_index = lines.index('*yForwardCoefficients 21 2')
        ycoeff_forward = coeffs_from_pcf(degree, lines[ycoeff_index + 1: ycoeff_index + 22])
        y_poly_forward = models.Polynomial2D(degree, name='y_poly_forward', **ycoeff_forward)

        xcoeff_index = lines.index('*xBackwardCoefficients 21 2')
        xcoeff_backward = coeffs_from_pcf(degree, lines[xcoeff_index + 1: xcoeff_index + 22])
        x_poly_backward = models.Polynomial2D(degree, name='x_poly_backward', **xcoeff_backward)

        ycoeff_index = lines.index('*yBackwardCoefficients 21 2')
        ycoeff_backward = coeffs_from_pcf(degree, lines[ycoeff_index + 1: ycoeff_index + 22])
        y_poly_backward = models.Polynomial2D(degree, name='y_poly_backward', **ycoeff_backward)

        output2poly_mapping = Identity(2, name='output_mapping')
        output2poly_mapping.inverse = Mapping([0, 1, 0, 1])
        input2poly_mapping = Mapping([0, 1, 0, 1], name='input_mapping')
        input2poly_mapping.inverse = Identity(2)

        model_poly = input2poly_mapping | (x_poly_forward & y_poly_forward) | output2poly_mapping

        model = linear_sky2det | model_poly
        fa.tree[n]['model'] = model
    asdffile = fa.write_to(outname)
    return asdffile
开发者ID:sosey,项目名称:jwreftools,代码行数:60,代码来源:nirspec_fs_ref_tools.py

示例8: detector_to_gwa

def detector_to_gwa(reference_files, detector, disperser):
    """
    Transform from DETECTOR frame to GWA frame.

    Parameters
    ----------
    reference_files: dict
        Dictionary with reference files returned by CRDS.
    detector : str
        The detector keyword.
    disperser : dict
        A corrected disperser ASDF object.

    Returns
    -------
    model : `~astropy.modeling.core.Model` model.
        Transform from DETECTOR frame to GWA frame.

    """
    with AsdfFile.open(reference_files['fpa']) as f:
        fpa = f.tree[detector].copy()
    with AsdfFile.open(reference_files['camera']) as f:
        camera = f.tree['model'].copy()

    angles = [disperser['theta_x'], disperser['theta_y'],
               disperser['theta_z'], disperser['tilt_y']]
    rotation = Rotation3DToGWA(angles, axes_order="xyzy", name='rotaton')
    u2dircos = Unitless2DirCos(name='unitless2directional_cosines')
    model = (models.Shift(-1) & models.Shift(-1) | fpa | camera | u2dircos | rotation)
    return model
开发者ID:philhodge,项目名称:jwst,代码行数:30,代码来源:nirspec.py

示例9: ifu_slicer2asdf

def ifu_slicer2asdf(ifuslicer, outname):
    """
    Create an asdf reference file with the MSA description.

    ifu_slicer2asdf("IFU_slicer.sgd", "ifu_slicer.asdf")

    Parameters
    ----------
    ifuslicer : str
        A fits file with the IFU slicer description
    outname : str
        Name of output ASDF file.
    """
    ref_kw = common_reference_file_keywords("IFUSLICER", "NIRSPEC IFU SLICER description - CDP4")
    f = fits.open(ifuslicer)
    tree = ref_kw.copy()
    data = f[1].data
    header = f[1].header
    shiftx = models.Shift(header['XREF'], name='ifu_slicer_xref')
    shifty = models.Shift(header['YREF'], name='ifu_slicer_yref')
    rot = models.Rotation2D(header['ROT'], name='ifu_slicer_rot')
    model = rot | shiftx & shifty
    tree['model'] = model
    tree['data'] = f[1].data
    f.close()
    fasdf = AsdfFile()
    fasdf.tree = tree
    fasdf.write_to(outname)
    return fasdf
开发者ID:sosey,项目名称:jwreftools,代码行数:29,代码来源:nirspec_fs_ref_tools.py

示例10: prism2asdf

def prism2asdf(prifile, tiltyfile, tiltxfile, outname):
    """Create a NIRSPEC prism disperser reference file in ASDF format.

    Combine information stored in disperser_G?.dis and disperser_G?_TiltY.gtp
    files delievred by the IDT.


    Parameters
    ----------
    prifile : list or str
        File with primary information for the PRSIM
    tiltyfile : str
        File with tilt_Y data, e.g. disperser_PRISM_TiltY.gtp.
    tiltxfile: str
        File with tilt_x data, e.g. disperser_PRISM_TiltX.gtp.
    outname : str
        Name of output ASDF file.

    Returns
    -------
    fasdf : asdf.AsdfFile

    """

    params = common_reference_file_keywords("PRISM", "NIRSPEC PRISM Model")
    flist = [prifile, tiltyfile, tiltxfile]

    # translate the files
    for fname in flist:
        try:
            refparams = dict_from_file(fname)
        except:
            print("Disperser file was not converted.")
            raise

        pdict = {}
        coeffs = {}
        parts = fname.lower().split(".")[0]
        ref = str("_".join(parts.split("_")[1:]))

        if "pri" not in fname:
            try:
                for i, c in enumerate(refparams['CoeffsTemperature00']):
                    coeffs['c' + str(i)] = c
                pdict['tilt_model'] = models.Polynomial1D(len(coeffs)-1, **coeffs)
                del refparams['CoeffsTemperature00']
            except KeyError:
                print("Missing CoeffsTemperature in {0}".format(fname))
                raise

        # store the rest of the keys
        for k, v in refparams.items():
            pdict[k] = v
        print(pdict)
        params[ref] = pdict

    fasdf = AsdfFile()
    fasdf.tree = params
    fasdf.write_to(outname)
    return fasdf
开发者ID:sosey,项目名称:jwreftools,代码行数:60,代码来源:nirspec_fs_ref_tools.py

示例11: ifuslit_to_msa

def ifuslit_to_msa(slits, reference_files):
    """
    The transform from slit_frame to msa_frame.

    Parameters
    ----------
    slits_id : list
        A list of slit IDs for all open shutters/slitlets.
    msafile : str
        The name of the msa reference file.

    Returns
    -------
    model : `~jwst_lib.pipeline_models.Slit2Msa` model.
        Transform from slit_frame to msa_frame.
    """
    with AsdfFile.open(reference_files['ifufore']) as f:
        ifufore = f.tree['model']

    ifuslicer = AsdfFile.open(reference_files['ifuslicer'])
    models = {}
    ifuslicer_model = (ifuslicer.tree['model']).rename('ifuslicer_model')
    for slit in slits:
        slitdata = ifuslicer.tree['data'][slit]
        slitdata_model = (get_slit_location_model(slitdata)).rename('slitdata_model')
        msa_transform = slitdata_model | ifuslicer_model
        models[slit] = msa_transform
    ifuslicer.close()

    return Slit2Msa(models)
开发者ID:hbushouse,项目名称:jwst,代码行数:30,代码来源:nirspec.py

示例12: calc_cube

def calc_cube(numb, fried_parameter = 4, time_between = 0.7):
    filepath = os.getcwd().split("vApp_reduction",1)[0]+"vApp_reduction/data/psf_cube_cache/"
    filepath += "psf_cube_"+str(float(fried_parameter))+"_"+str(float(time_between))+"_"+str(int(numb))+".asdf"

    #expand to only demand numb =< numb on disk
    if os.path.exists(filepath):

        tree = AsdfFile.open(filepath, copy_arrays=True).tree
        tree_keys = tree.keys()
        psf_params = sorted(list(filter(lambda key: isinstance(key, float), tree_keys)))
        psf_cube = list(map(lambda param: np.copy(tree[param]), psf_params))
        return psf_cube, psf_params
    else:
        path =  os.getcwd()+"/code/psf/generate_vAPP_cube.py"
        params = [str(fried_parameter), str(time_between), str(numb)]
        cmd = [sys.executable, path, *params]
        print("please run: ")
        print(' '.join(cmd))
        input("Press Enter to continue...")

        tree = AsdfFile.open(filepath).tree
        tree_keys = tree.keys()
        psf_params = sorted(list(filter(lambda key: isinstance(key, float), tree_keys)))
        psf_cube = list(map(lambda param: tree[param], psf_params))

        return psf_cube, psf_params
开发者ID:dskleingeld,项目名称:vApp_reduction,代码行数:26,代码来源:from_simulated_psf.py

示例13: pcf_forward

def pcf_forward(pcffile, outname):
    """
    Create the **IDT** forward transform from collimator to gwa.
    """
    with open(pcffile) as f:
        lines = [l.strip() for l in f.readlines()]

    factors = lines[lines.index('*Factor 2') + 1].split()
    # factor==1/factor in backward msa2ote direction and factor==factor in sky2detector direction
    scale = models.Scale(float(factors[0]), name="x_scale") & \
          models.Scale(float(factors[1]), name="y_scale")

    rotation_angle = lines[lines.index('*Rotation') + 1]
    # The minius sign here is because astropy.modeling has the opposite direction of rotation than the idl implementation
    rotation = models.Rotation2D(-float(rotation_angle), name='rotation')


    # Here the model is called "output_shift" but in the team version it is the "input_shift".
    input_rot_center = lines[lines.index('*InputRotationCentre 2') + 1].split()
    input_rot_shift = models.Shift(-float(input_rot_center[0]), name='input_x_shift') & \
                 models.Shift(-float(input_rot_center[1]), name='input_y_shift')


    # Here the model is called "input_shift" but in the team version it is the "output_shift".
    output_rot_center = lines[lines.index('*OutputRotationCentre 2') + 1].split()
    output_rot_shift = models.Shift(float(output_rot_center[0]), name='output_x_shift') & \
                  models.Shift(float(output_rot_center[1]), name='output_y_shift')

    degree = int(lines[lines.index('*FitOrder') + 1])
    xcoeff_index = lines.index('*xForwardCoefficients 21 2')
    xlines = lines[xcoeff_index + 1: xcoeff_index + 22]
    xcoeff_forward = coeffs_from_pcf(degree, xlines)
    x_poly_forward = models.Polynomial2D(degree, name='x_poly_forward', **xcoeff_forward)

    ycoeff_index = lines.index('*yForwardCoefficients 21 2')
    ycoeff_forward = coeffs_from_pcf(degree, lines[ycoeff_index + 1: ycoeff_index + 22])
    y_poly_forward = models.Polynomial2D(degree, name='y_poly_forward', **ycoeff_forward)

    xcoeff_index = lines.index('*xBackwardCoefficients 21 2')
    xcoeff_backward = coeffs_from_pcf(degree, lines[xcoeff_index + 1: xcoeff_index + 22])
    x_poly_backward = models.Polynomial2D(degree, name='x_poly_backward', **xcoeff_backward)

    ycoeff_index = lines.index('*yBackwardCoefficients 21 2')
    ycoeff_backward = coeffs_from_pcf(degree, lines[ycoeff_index + 1: ycoeff_index + 22])
    y_poly_backward = models.Polynomial2D(degree, name='y_poly_backward', **ycoeff_backward)

    x_poly_forward.inverse = x_poly_backward
    y_poly_forward.inverse = y_poly_backward

    poly_mapping1  = Mapping((0, 1, 0, 1))
    poly_mapping1.inverse = Identity(2)
    poly_mapping2 = Identity(2)
    poly_mapping2.inverse = Mapping((0, 1, 0, 1))

    model = input_rot_shift | rotation | scale | output_rot_shift | \
          poly_mapping1 | x_poly_forward & y_poly_forward | poly_mapping2
    f = AsdfFile()
    f.tree = {'model': model}
    f.write_to(outname)
开发者ID:sosey,项目名称:jwreftools,代码行数:59,代码来源:nirspec_fs_ref_tools.py

示例14: ote2asdf

def ote2asdf(otepcf, outname, ref_kw):
    """
    ref_kw = common_reference_file_keywords('OTE', 'NIRSPEC OTE transform - CDP4')

    ote2asdf('Model/Ref_Files/CoordTransform/OTE.pcf', 'jwst_nirspec_ote_0001.asdf', ref_kw)
    """
    with open(otepcf) as f:
        lines = [l.strip() for l in f.readlines()]

    factors = lines[lines.index('*Factor 2 1') + 1].split()
    # this corresponds to modeling Rotation direction as is
    rotation_angle = float(lines[lines.index('*Rotation') + 1])
    input_rot_center = lines[lines.index('*InputRotationCentre 2 1') + 1].split()
    output_rot_center = lines[lines.index('*OutputRotationCentre 2 1') + 1].split()

    mlinear = homothetic_det2sky(input_rot_center, rotation_angle, factors, output_rot_center)

    degree = int(lines[lines.index('*FitOrder') + 1])

    xcoeff_index = lines.index('*xBackwardCoefficients 21 2')
    xlines = lines[xcoeff_index + 1].split('\t')
    xcoeff_backward = coeffs_from_pcf(degree, xlines)
    x_poly_forward = models.Polynomial2D(degree, name='x_poly_forward', **xcoeff_backward)

    xcoeff_index = lines.index('*xForwardCoefficients 21 2')
    xlines = lines[xcoeff_index + 1].split('\t')
    xcoeff_forward = coeffs_from_pcf(degree, xlines)
    x_poly_backward = models.Polynomial2D(degree, name='x_poly_backward', **xcoeff_forward)

    ycoeff_index = lines.index('*yBackwardCoefficients 21 2')
    ylines = lines[ycoeff_index + 1].split('\t')
    ycoeff_backward = coeffs_from_pcf(degree, ylines)
    y_poly_forward = models.Polynomial2D(degree, name='y_poly_forward', **ycoeff_backward)

    ycoeff_index = lines.index('*yForwardCoefficients 21 2')
    ylines = lines[ycoeff_index + 1].split('\t')
    ycoeff_forward = coeffs_from_pcf(degree, ylines)
    y_poly_backward = models.Polynomial2D(degree, name='y_poly_backward', **ycoeff_forward)

    x_poly_forward.inverse = x_poly_backward
    y_poly_forward.inverse = y_poly_backward

    output2poly_mapping = Identity(2, name='output_mapping')
    output2poly_mapping.inverse = Mapping([0, 1, 0, 1])
    input2poly_mapping = Mapping([0, 1, 0, 1], name='input_mapping')
    input2poly_mapping.inverse = Identity(2)

    model_poly = input2poly_mapping | (x_poly_forward & y_poly_forward) | output2poly_mapping

    model = model_poly | mlinear


    f = AsdfFile()
    f.tree = ref_kw.copy()
    f.tree['model'] = model
    f.write_to(outname)
    return model_poly, mlinear
开发者ID:sosey,项目名称:jwreftools,代码行数:57,代码来源:nirspec_fs_ref_tools.py

示例15: create_v23

def create_v23(reftype, detector, band, channels, data, name):
    """
    Create the transform from MIRI Local to telescope V2/V3 system for all channels.
    """
    channel = "".join([ch[0] for ch in channels])
    tree = {"detector": detector,
            "instrument" : "MIRI",
            "band": band,
            "channel": channel,
            "exp_type": "MIR_MRS",
            "pedigree": "GROUND",
            "title": "MIRI IFU model - based on CDP-4",
            "reftype": reftype,
            "author": "N. Dencheva"
            }
    ab_v23 = data[0]
    v23_ab = data[1]
    m = {}
    c0_0, c0_1, c1_0, c1_1 = ab_v23[0][1:]
    ch1_v2 = models.Polynomial2D(2, c0_0=c0_0, c1_0=c1_0, c0_1=c0_1, c1_1=c1_1,
                                 name="ab_v23")
    c0_0, c0_1, c1_0, c1_1 = v23_ab[0][1:]
    ch1_a = models.Polynomial2D(2, c0_0=c0_0, c1_0=c1_0, c0_1=c0_1, c1_1=c1_1,
                                name="v23_ab")

    c0_0, c0_1, c1_0, c1_1 = ab_v23[1][1:]
    ch1_v3 = models.Polynomial2D(2, c0_0=c0_0, c1_0=c1_0, c0_1=c0_1, c1_1=c1_1,
                                 name="ab_v23")
    c0_0, c0_1, c1_0, c1_1 = v23_ab[1][1:]
    ch1_b = models.Polynomial2D(2, c0_0=c0_0, c1_0=c1_0, c0_1=c0_1, c1_1=c1_1,
                                name="v23_ab")
    c0_0, c0_1, c1_0, c1_1 = ab_v23[2][1:]
    ch2_v2 = models.Polynomial2D(2, c0_0=c0_0, c1_0=c1_0, c0_1=c0_1, c1_1=c1_1,
                                 name="ab_v23")
    c0_0, c0_1, c1_0, c1_1 = v23_ab[2][1:]
    ch2_a = models.Polynomial2D(2, c0_0=c0_0, c1_0=c1_0, c0_1=c0_1, c1_1=c1_1,
                                name="v23_ab")

    c0_0, c0_1, c1_0, c1_1 = ab_v23[3][1:]
    ch2_v3 = models.Polynomial2D(2, c0_0=c0_0, c1_0=c1_0, c0_1=c0_1, c1_1=c1_1,
                                 name="ab_v23")
    c0_0, c0_1, c1_0, c1_1 = v23_ab[3][1:]
    ch2_b = models.Polynomial2D(2, c0_0=c0_0, c1_0=c1_0, c0_1=c0_1, c1_1=c1_1,
                                name="v23_ab")
    ch1_for =  ch1_v2 & ch1_v3
    ch2_for = ch2_v2 & ch2_v3
    ch1_for.inverse =  ch1_a & ch1_b
    ch2_for.inverse =  ch2_a & ch2_b
    m[channels[0]] = ch1_for
    m[channels[1]] = ch2_for
    tree['model'] = m

    f = AsdfFile()
    f.tree = tree
    f.write_to(name)
开发者ID:hbushouse,项目名称:jwst,代码行数:55,代码来源:miri_ifu_ref_tools.py


注:本文中的asdf.AsdfFile类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。