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


Python EarthLocation.from_geocentric方法代码示例

本文整理汇总了Python中astropy.coordinates.EarthLocation.from_geocentric方法的典型用法代码示例。如果您正苦于以下问题:Python EarthLocation.from_geocentric方法的具体用法?Python EarthLocation.from_geocentric怎么用?Python EarthLocation.from_geocentric使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在astropy.coordinates.EarthLocation的用法示例。


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

示例1: from_itrf

# 需要导入模块: from astropy.coordinates import EarthLocation [as 别名]
# 或者: from astropy.coordinates.EarthLocation import from_geocentric [as 别名]
    def from_itrf(ant_itrf_xyz, ant_labels):
        """
        Instantiate telescope model from ITRF co-ordinates of antennae

        (aka ECEF-coords, i.e. Earth-Centered-Earth-Fixed reference frame.)

        Takes care of calculating central Latitude and Longitude from the mean
        antenna position, and converts the antenna positions into local-XYZ
        frame.

        Args:
            ant_itrf_xyz (numpy.ndarray): Array co-ordinatates in the ITRF frame
            ant_labels (list[str]): Antennae labels
        Returns:
            Telescope: A telescope class with the given array co-ords.
        """
        mean_posn = np.mean(ant_itrf_xyz, axis=0)
        centre = EarthLocation.from_geocentric(mean_posn[0],
                                               mean_posn[1],
                                               mean_posn[2],
                                               unit=u.m,
                                               )
        lon, lat, height = centre.to_geodetic()

        mean_subbed_itrf = ant_itrf_xyz - mean_posn

        rotation = z_rotation_matrix(lon)
        ant_local_xyz = np.dot(rotation, mean_subbed_itrf.T).T

        return Telescope(
            centre=centre,
            ant_labels=ant_labels,
            ant_itrf_xyz=ant_itrf_xyz,
            ant_local_xyz=ant_local_xyz,
        )
开发者ID:SKA-ScienceDataProcessor,项目名称:FastImaging-Python,代码行数:37,代码来源:base.py

示例2: earth_location_itrf

# 需要导入模块: from astropy.coordinates import EarthLocation [as 别名]
# 或者: from astropy.coordinates.EarthLocation import from_geocentric [as 别名]
    def earth_location_itrf(self, time=None):
        '''Return Fermi spacecraft location in ITRF coordinates'''

        if self.tt2tdb_mode.lower().startswith('none'):
            log.warning('Using location=None for TT to TDB conversion')
            return None
        elif self.tt2tdb_mode.lower().startswith('geo'):
            log.warning('Using location geocenter for TT to TDB conversion')
            return EarthLocation.from_geocentric(0.0*u.m,0.0*u.m,0.0*u.m)
        elif self.tt2tdb_mode.lower().startswith('spacecraft'):
            # First, interpolate Earth-Centered Inertial (ECI) geocentric
            # location from orbit file.
            # These are inertial coordinates aligned with ICRS, called GCRS
            # <http://docs.astropy.org/en/stable/api/astropy.coordinates.GCRS.html>
            pos_gcrs =  GCRS(CartesianRepresentation(self.X(time.tt.mjd)*u.m,
                                                     self.Y(time.tt.mjd)*u.m,
                                                     self.Z(time.tt.mjd)*u.m),
                             obstime=time)

            # Now transform ECI (GCRS) to ECEF (ITRS)
            # By default, this uses the WGS84 ellipsoid
            pos_ITRS = pos_gcrs.transform_to(ITRS(obstime=time))

            # Return geocentric ITRS coordinates as an EarthLocation object
            return pos_ITRS.earth_location
        else:
            log.error('Unknown tt2tdb_mode %s, using None', self.tt2tdb_mode)
            return None
开发者ID:scottransom,项目名称:PINT,代码行数:30,代码来源:fermi_obs.py

示例3: eci2el

# 需要导入模块: from astropy.coordinates import EarthLocation [as 别名]
# 或者: from astropy.coordinates.EarthLocation import from_geocentric [as 别名]
def eci2el(x,y,z,dt):
    """
    Convert Earth-Centered Inertial (ECI) cartesian coordinates to ITRS for astropy EarthLocation object.

    Inputs :
    x = ECI X-coordinate 
    y = ECI Y-coordinate 
    z = ECI Z-coordinate 
    dt = UTC time (datetime object)
    """

    from astropy.coordinates import GCRS, ITRS, EarthLocation, CartesianRepresentation
    import astropy.units as u
    
    # convert datetime object to astropy time object
    tt=Time(dt,format='datetime')

    # Read the coordinates in the Geocentric Celestial Reference System
    gcrs = GCRS(CartesianRepresentation(x=x, y=y,z=z), obstime=tt)

    # Convert it to an Earth-fixed frame
    itrs = gcrs.transform_to(ITRS(obstime=tt))

    el = EarthLocation.from_geocentric(itrs.x, itrs.y, itrs.z) 

    return el
开发者ID:NuSTAR,项目名称:nustar_pysolar,代码行数:28,代码来源:tracking.py

示例4: from_tree

# 需要导入模块: from astropy.coordinates import EarthLocation [as 别名]
# 或者: from astropy.coordinates.EarthLocation import from_geocentric [as 别名]
    def from_tree(cls, node, ctx):
        if isinstance(node, (str, list, np.ndarray)):
            t = time.Time(node)
            format = _astropy_format_to_asdf_format.get(t.format, t.format)
            if format not in _guessable_formats:
                raise ValueError("Invalid time '{0}'".format(node))
            return t

        value = node['value']
        format = node.get('format')
        scale = node.get('scale')
        location = node.get('location')
        if location is not None:
            unit = location.get('unit', u.m)
            # This ensures that we can read the v.1.0.0 schema and convert it
            # to the new EarthLocation object, which expects Quantity components
            for comp in ['x', 'y', 'z']:
                if not isinstance(location[comp], Quantity):
                    location[comp] = Quantity(location[comp], unit=unit)
            location = EarthLocation.from_geocentric(
                location['x'], location['y'], location['z'])

        return time.Time(value, format=format, scale=scale, location=location)
开发者ID:Juanlu001,项目名称:astropy,代码行数:25,代码来源:time.py

示例5: earth_location_itrf

# 需要导入模块: from astropy.coordinates import EarthLocation [as 别名]
# 或者: from astropy.coordinates.EarthLocation import from_geocentric [as 别名]
    def earth_location_itrf(self, time=None):
        '''Return NICER spacecraft location in ITRF coordinates'''

        if self.tt2tdb_mode.lower().startswith('none'):
            return None
        elif self.tt2tdb_mode.lower().startswith('geo'):
            return EarthLocation.from_geocentric(0.0*u.m,0.0*u.m,0.0*u.m)
        elif self.tt2tdb_mode.lower().startswith('spacecraft'):
            # First, interpolate ECI geocentric location from orbit file.
            # These are inertial coorinates aligned with ICRF
            pos_gcrs =  GCRS(CartesianRepresentation(self.X(time.tt.mjd)*u.m,
                                                     self.Y(time.tt.mjd)*u.m,
                                                     self.Z(time.tt.mjd)*u.m),
                             obstime=time)

            # Now transform ECI (GCRS) to ECEF (ITRS)
            # By default, this uses the WGS84 ellipsoid
            pos_ITRS = pos_gcrs.transform_to(ITRS(obstime=time))

            # Return geocentric ITRS coordinates as an EarthLocation object
            return pos_ITRS.earth_location
        else:
            log.error('Unknown tt2tdb_mode %s, using None', self.tt2tdb_mode)
            return None
开发者ID:scottransom,项目名称:PINT,代码行数:26,代码来源:nicer_obs.py

示例6: __init__

# 需要导入模块: from astropy.coordinates import EarthLocation [as 别名]
# 或者: from astropy.coordinates.EarthLocation import from_geocentric [as 别名]
    def __init__(self, name, tempo_code=None, itoa_code=None, aliases=None,
                 itrf_xyz=None, clock_file='time.dat', clock_dir='PINT',
                 clock_fmt='tempo', include_gps=True, include_bipm=True,
                 bipm_version='BIPM2015'):
        """
        Required arguments:

            name     = The name of the observatory
            itrf_xyz = IRTF site coordinates (len-3 array).  Can include
                       astropy units.  If no units are given, meters are
                       assumed.

        Optional arguments:

            tempo_code  = 1-character tempo code for the site.  Will be
                          automatically added to aliases.  Note, this is
                          REQUIRED only if using TEMPO time.dat clock file.
            itoa_code   = 2-character ITOA code.  Will be added to aliases.
            aliases     = List of other aliases for the observatory name.
            clock_file  = Name of the clock correction file.
                          Default='time.dat'
            clock_dir   = Location of the clock file.  Special values
                          'TEMPO', 'TEMPO2', or 'PINT' mean to use the
                          standard directory for the package.  Otherwise
                          can be set to a full path to the directory
                          containing the clock_file.  Default='TEMPO'
            clock_fmt   = Format of clock file (see ClockFile class for allowed
                          values).  Default='tempo'
            include_gps = Set False to disable UTC(GPS)->UTC clock
                          correction.
            include_bipm= Set False to disable UTC-> TT BIPM clock
                          correction. If False, it only apply TAI->TT correction
                          TT = TAI+32.184s, the same as TEMPO2 TT(TAI) in the
                          parfile. If Ture, it will apply the correction from
                          BIPM TT=TT(BIPMYYYY). See the link:
                          http://www.bipm.org/en/bipm-services/timescales/time-ftp/ttbipm.html
            bipm_version= Set the version of TT BIPM clock correction file to
                          use, the default is BIPM2015.  It has to be in the format
                          like 'BIPM2015'
        """

        # ITRF coordinates are required
        if itrf_xyz is None:
            raise ValueError(
                    "ITRF coordinates not given for observatory '%s'" % name)

        # Convert coords to standard format.  If no units are given, assume
        # meters.
        if not has_astropy_unit(itrf_xyz):
            xyz = numpy.array(itrf_xyz) * u.m
        else:
            xyz = itrf_xyz.to(u.m)

        # Check for correct array dims
        if xyz.shape != (3,):
            raise ValueError(
                    "Incorrect coordinate dimensions for observatory '%s'" % (
                        name))

        # Convert to astropy EarthLocation, ensuring use of ITRF geocentric coordinates
        self._loc_itrf = EarthLocation.from_geocentric(*xyz)

        # Save clock file info, the data will be read only if clock
        # corrections for this site are requested.
        self.clock_file = clock_file
        self.clock_dir = clock_dir
        self.clock_fmt = clock_fmt
        self._clock = None # The ClockFile object, will be read on demand

        # If using TEMPO time.dat we need to know the 1-char tempo-style
        # observatory code.
        if (clock_dir=='TEMPO' and clock_file=='time.dat'
                and tempo_code is None):
            raise ValueError("No tempo_code set for observatory '%s'" % name)

        # GPS corrections not implemented yet
        self.include_gps = include_gps
        self._gps_clock = None

        # BIPM corrections not implemented yet
        self.include_bipm = include_bipm
        self.bipm_version = bipm_version
        self._bipm_clock = None

        self.tempo_code = tempo_code
        if aliases is None: aliases = []
        for code in (tempo_code, itoa_code):
            if code is not None: aliases.append(code)

        super(TopoObs,self).__init__(name,aliases=aliases)
开发者ID:scottransom,项目名称:PINT,代码行数:92,代码来源:topo_obs.py

示例7: earth_location

# 需要导入模块: from astropy.coordinates import EarthLocation [as 别名]
# 或者: from astropy.coordinates.EarthLocation import from_geocentric [as 别名]
 def earth_location(self):
     return EarthLocation.from_geocentric(0.0,0.0,0.0,unit=u.m)
开发者ID:,项目名称:,代码行数:4,代码来源:

示例8: _verify_global_info

# 需要导入模块: from astropy.coordinates import EarthLocation [as 别名]
# 或者: from astropy.coordinates.EarthLocation import from_geocentric [as 别名]
def _verify_global_info(global_info):
    """
    Given the global time reference frame information, verify that
    each global time coordinate attribute will be given a valid value.

    Parameters
    ----------
    global_info : dict
        Global time reference frame information.
    """

    # Translate FITS deprecated scale into astropy scale, or else just convert
    # to lower case for further checks.
    global_info['scale'] = FITS_DEPRECATED_SCALES.get(global_info['TIMESYS'],
                                                      global_info['TIMESYS'].lower())

    # Verify global time scale
    if global_info['scale'] not in Time.SCALES:

        # 'GPS' and 'LOCAL' are FITS recognized time scale values
        # but are not supported by astropy.

        if global_info['scale'] == 'gps':
            warnings.warn(
                'Global time scale (TIMESYS) has a FITS recognized time scale '
                'value "GPS". In Astropy, "GPS" is a time from epoch format '
                'which runs synchronously with TAI; GPS is approximately 19 s '
                'ahead of TAI. Hence, this format will be used.', AstropyUserWarning)
            # Assume that the values are in GPS format
            global_info['scale'] = 'tai'
            global_info['format'] = 'gps'

        if global_info['scale'] == 'local':
            warnings.warn(
                'Global time scale (TIMESYS) has a FITS recognized time scale '
                'value "LOCAL". However, the standard states that "LOCAL" should be '
                'tied to one of the existing scales because it is intrinsically '
                'unreliable and/or ill-defined. Astropy will thus use the default '
                'global time scale "UTC" instead of "LOCAL".', AstropyUserWarning)
            # Default scale 'UTC'
            global_info['scale'] = 'utc'
            global_info['format'] = None

        else:
            raise AssertionError(
                'Global time scale (TIMESYS) should have a FITS recognized '
                'time scale value (got {!r}). The FITS standard states that '
                'the use of local time scales should be restricted to alternate '
                'coordinates.'.format(global_info['TIMESYS']))
    else:
        # Scale is already set
        global_info['format'] = None

    # Check if geocentric global location is specified
    obs_geo = [global_info[attr] for attr in ('OBSGEO-X', 'OBSGEO-Y', 'OBSGEO-Z')
               if attr in global_info]

    # Location full specification is (X, Y, Z)
    if len(obs_geo) == 3:
        global_info['location'] = EarthLocation.from_geocentric(*obs_geo, unit=u.m)
    else:
        # Check if geodetic global location is specified (since geocentric failed)

        # First warn the user if geocentric location is partially specified
        if obs_geo:
            warnings.warn(
                'The geocentric observatory location {} is not completely '
                'specified (X, Y, Z) and will be ignored.'.format(obs_geo),
                AstropyUserWarning)

        # Check geodetic location
        obs_geo = [global_info[attr] for attr in ('OBSGEO-L', 'OBSGEO-B', 'OBSGEO-H')
                   if attr in global_info]

        if len(obs_geo) == 3:
            global_info['location'] = EarthLocation.from_geodetic(*obs_geo)
        else:
            # Since both geocentric and geodetic locations are not specified,
            # location will be None.

            # Warn the user if geodetic location is partially specified
            if obs_geo:
                warnings.warn(
                    'The geodetic observatory location {} is not completely '
                    'specified (lon, lat, alt) and will be ignored.'.format(obs_geo),
                    AstropyUserWarning)
            global_info['location'] = None

    # Get global time reference
    # Keywords are listed in order of precedence, as stated by the standard
    for key, format_ in (('MJDREF', 'mjd'), ('JDREF', 'jd'), ('DATEREF', 'fits')):
        if key in global_info:
            global_info['ref_time'] = {'val': global_info[key], 'format': format_}
            break
    else:
        # If none of the three keywords is present, MJDREF = 0.0 must be assumed
        global_info['ref_time'] = {'val': 0, 'format': 'mjd'}
开发者ID:Cadair,项目名称:astropy,代码行数:99,代码来源:fitstime.py

示例9: earth_location_itrf

# 需要导入模块: from astropy.coordinates import EarthLocation [as 别名]
# 或者: from astropy.coordinates.EarthLocation import from_geocentric [as 别名]
 def earth_location_itrf(self, time=None):
     return EarthLocation.from_geocentric(0.0,0.0,0.0,unit=u.m)
开发者ID:scottransom,项目名称:PINT,代码行数:4,代码来源:special_locations.py


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