コード例 #1
0
ファイル: i_oc_calc.py プロジェクト: AstrolabeProject/imdtk
    def calc_field_value(self, field_name, defaults, wcs_info, metadata,
                         calculations):
        """
        Provide the opportunity to calculate (or recalculate) a value for the named field.
        This version may call abstract methods which call down to the concrete methods.
        """
        if (field_name in ['s_ra', 's_dec']):
            occ_utils.calc_wcs_coordinates(wcs_info, metadata, calculations)

        elif (field_name in ['im_naxis1', 'im_naxis2']):
            if (calculations.get('s_xel1') is not None):
                calculations['im_naxis1'] = calculations.get('s_xel1')
            if (calculations.get('s_xel2') is not None):
                calculations['im_naxis2'] = calculations.get('s_xel2')

        elif (field_name == 's_resolution'):
            self.calc_spatial_resolution(calculations)

        elif (field_name == 'im_pixtype'):
            occ_utils.calc_pixtype(metadata, calculations)

        elif (field_name in ['access_estsize', 'file_size']):
            occ_utils.calc_access_estsize(metadata, calculations)

        elif (field_name == 'access_url'):
            self.calc_access_url(metadata, calculations)
コード例 #2
0
 def test_calc_pixtype_byte(self):
     md = { 'headers': { 'BITPIX': 8 }}
     calcs = dict()
     utils.calc_pixtype(md, calcs)
     print(calcs)
     assert len(calcs) == 1
     assert calcs.get('im_pixtype') == 'byte'
コード例 #3
0
 def test_calc_pixtype_badpixval(self):
     md = { 'headers': { 'BITPIX': 2 }}
     calcs = dict()
     utils.calc_pixtype(md, calcs)
     print(calcs)
     assert len(calcs) == 1
     assert calcs.get('im_pixtype') == 'UNKNOWN'
コード例 #4
0
 def test_calc_pixtype_nobitpix(self):
     md = { 'headers': { 'NAXIS': 2 }}
     calcs = dict()
     utils.calc_pixtype(md, calcs)
     print(calcs)
     assert len(calcs) == 0
     assert calcs.get('im_pixtype') == None
コード例 #5
0
 def test_calc_pixtype_double_str(self):
     md = { 'headers': { 'BITPIX': '-64' }}
     calcs = dict()
     utils.calc_pixtype(md, calcs)
     print(calcs)
     assert len(calcs) == 1
     assert calcs.get('im_pixtype') == 'double'