Environment (pyobs.environment)

class Environment(timezone: str = 'utc', location: Optional[Union[Dict[str, Any], EarthLocation]] = None, *args: Any, **kwargs: Any)[source]

An Environment object hold information about the location of the observatory and provides some convenience methode.

An object of this type is usually never instantiated manually, but is part of a Module, automatically created from the configuration file like this:

timezone: Africa/Johannesburg
location:
    longitude: 20.810808
    latitude: -32.375823
    elevation: 1798.
localtime(utc: Optional[datetime] = None) datetime[source]

Returns the local time at the observatory, either for a given UTC time or for now, if none is given.

Parameters:

utc – UTC to convert. Use now if none is given.

Returns:

Local time.

property location: Optional[EarthLocation]

Returns the location of the observatory.

lst(time: Union[datetime, Time]) Longitude[source]

Returns the local sidereal time for a given time.

Parameters:

time – Time to convert to LST.

Returns:

Local sidereal time.

night_obs(time: Optional[Union[datetime, Time]] = None) date[source]

Returns the date of the night for the given night, i.e. the date of the start of the night.

Parameters:

time – Time to return night for. If none is given, current time is used.

Returns:

Night of observation.

now() Time[source]

Returns current time.

sun(time: Time, altaz: bool = True) SkyCoord[source]

Returns the position of the sun, either as RA/Dec or Alt/Az for the given time.

Parameters:
  • time – Time to calculate position for.

  • altaz – If True, Alt/Az is returned, otherwise RA/Dec.

Returns:

Coordinates of sun.

property timezone: tzinfo

Returns the timezone of the observatory.

to_altaz(radec: SkyCoord, time: Optional[Time] = None) SkyCoord[source]

Converts a given set of RA/Dec to Alt/Az for the current location at a given time.

Parameters:
  • radec – RA/Dec coordinates to convert.

  • time – Time to use, or none for now.

Returns:

Alt/Az coordinates for given RA/Dec.

to_radec(altaz: SkyCoord, time: Optional[Time] = None) SkyCoord[source]

Converts a given set of Alt/Az to RA/Dec for the current location at a given time.

Parameters:
  • altaz – Alt/Az coordinates to convert.

  • time – Time to use, or none for now.

Returns:

RA/Dec coordinates for given Alt/Az.

zenith_position(lst: Longitude) SkyCoord[source]

Returns the RA/Dec position of the zenith.

Parameters:

lst – Local sidereal time to use.

Returns:

SkyCoord with current zenith position.