Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def acquisition_time(self, timeformat='unix'):
"""Returns the UTC time telling when the image data was acquired by the satellite
:param timeformat: the format for the time value. May be:
'*unix*' (default) for UNIX time
'*iso*' for ISO8601-formatted string in the format ``YYYY-MM-DD HH:MM:SS+00``
'*date* for ``datetime.datetime`` object instance
:type timeformat: str
:returns: an int or a str
"""
return formatting.timeformat(self._acquisition_time, timeformat)
def reference_time(self, timeformat='unix'):
"""
Returns the GMT time telling when the SO2 samples have been measured
:param timeformat: the format for the time value. May be:
'*unix*' (default) for UNIX time
'*iso*' for ISO8601-formatted string in the format ``YYYY-MM-DD HH:MM:SS+00``
'*date* for ``datetime.datetime`` object instance
:type timeformat: str
:returns: an int or a str
:raises: ValueError when negative values are provided
"""
return formatting.timeformat(self.ref_time, timeformat)
def reference_time(self, timeformat='unix'):
"""
Returns the GMT time telling when the CO samples have been measured
:param timeformat: the format for the time value. May be:
'*unix*' (default) for UNIX time
'*iso*' for ISO8601-formatted string in the format ``YYYY-MM-DD HH:MM:SS+00``
'*date* for ``datetime.datetime`` object instance
:type timeformat: str
:returns: an int or a str
:raises: ValueError when negative values are provided
"""
return formatting.timeformat(self.ref_time, timeformat)
def creation_time(self, timeformat='unix'):
"""Returns the UTC time of creation of this station
:param timeformat: the format for the time value. May be:
'*unix*' (default) for UNIX time, '*iso*' for ISO8601-formatted
string in the format ``YYYY-MM-DD HH:MM:SS+00`` or `date` for
a ``datetime.datetime`` object
:type timeformat: str
:returns: an int or a str or a ``datetime.datetime`` object or None
:raises: ValueError
"""
if self.created_at is None:
return None
return formatting.timeformat(self.created_at, timeformat)
boundary (defaults to ``None``, in which case the current datetime
will be used)
:type end: int, ``datetime.datetime`` or ISO8601-formatted string
:return: a list of *UVIndex* instances or empty list if data is not available
:raises: *ParseResponseException* when OWM UV Index API responses' data
cannot be parsed, *APICallException* when OWM UV Index API can not be
reached, *ValueError* for wrong input values
"""
geo.assert_is_lon(lon)
geo.assert_is_lat(lat)
assert start is not None
start = formatting.timeformat(start, 'unix')
if end is None:
end = timestamps.now(timeformat='unix')
else:
end = formatting.timeformat(end, 'unix')
params = {'lon': lon, 'lat': lat, 'start': start, 'end': end}
json_data = self.uv_client.get_uvi_history(params)
uvindex_list = [uvindex.UVIndex.from_dict(item) for item in json_data]
return uvindex_list
raise ValueError("'alt' value must not be negative")
self.id = id
self.created_at = created_at
if self.created_at is not None:
padded_created_at = self._format_micros(created_at)
t = dt.strptime(padded_created_at,
'%Y-%m-%dT%H:%M:%S.%fZ').replace(
tzinfo=formatting.UTC())
self.created_at = formatting.timeformat(t, 'unix')
self.updated_at = updated_at
if self.updated_at is not None:
padded_updated_at = self._format_micros(updated_at)
t = dt.strptime(padded_updated_at,
'%Y-%m-%dT%H:%M:%S.%fZ').replace(
tzinfo=formatting.UTC())
self.updated_at = formatting.timeformat(t, 'unix')
self.external_id = external_id
self.name = name
self.lon = lon
self.lat = lat
self.alt = alt
self.rank = rank
def reception_time(self, timeformat='unix'):
"""
Returns the GMT time telling when the NO2 observation has been received
from the OWM Weather API
:param timeformat: the format for the time value. May be:
'*unix*' (default) for UNIX time
'*iso*' for ISO8601-formatted string in the format ``YYYY-MM-DD HH:MM:SS+00``
'*date* for ``datetime.datetime`` object instance
:type timeformat: str
:returns: an int or a str
:raises: ValueError when negative values are provided
"""
return formatting.timeformat(self.rec_time, timeformat)
def creation_time(self, timeformat='unix'):
"""Returns the UTC time of creation of this aggregated measurement
:param timeformat: the format for the time value. May be:
'*unix*' (default) for UNIX time, '*iso*' for ISO8601-formatted
string in the format ``YYYY-MM-DD HH:MM:SS+00`` or `date` for
a ``datetime.datetime`` object
:type timeformat: str
:returns: an int or a str or a ``datetime.datetime`` object or None
:raises: ValueError
"""
if self.created_at is None:
return None
return formatting.timeformat(self.created_at, timeformat)
def reference_time(self, timeformat='unix'):
"""
Returns the GMT time telling when the NO2 samples have been measured
:param timeformat: the format for the time value. May be:
'*unix*' (default) for UNIX time
'*iso*' for ISO8601-formatted string in the format ``YYYY-MM-DD HH:MM:SS+00``
'*date* for ``datetime.datetime`` object instance
:type timeformat: str
:returns: an int or a str
:raises: ValueError when negative values are provided
"""
return formatting.timeformat(self.ref_time, timeformat)
def creation_time(self, timeformat='unix'):
"""Returns the UTC time of creation of this aggregated measurement
:param timeformat: the format for the time value. May be:
'*unix*' (default) for UNIX time, '*iso*' for ISO8601-formatted
string in the format ``YYYY-MM-DD HH:MM:SS+00`` or `date` for
a ``datetime.datetime`` object
:type timeformat: str
:returns: an int or a str or a ``datetime.datetime`` object or None
:raises: ValueError
"""
if self.timestamp is None:
return None
return formatting.timeformat(self.timestamp, timeformat)