def _get_update_subsets_for_slice(self, slice): """ Returns the given slice's interval as a list of wcst subsets :param slice: the slice for which to generate this :rtype: list[WCSTSubset] """ subsets = [] for axis_subset in slice.axis_subsets: low = axis_subset.interval.low high = axis_subset.interval.high # if ConfigManager.subset_correction and high is not None and low != high and type(low) != str: if ConfigManager.subset_correction and high is not None and low != high and type(low) == str: # Time axis with type = str (e.g: "1970-01-01T02:03:06Z") time_seconds = 1 # AnsiDate (need to change from date to seconds) if axis_subset.coverage_axis.axis.crs_axis.is_time_day_axis(): time_seconds = DateTimeUtil.DAY_IN_SECONDS low = decimal.Decimal(str(arrow.get(low).float_timestamp)) + decimal.Decimal(str(axis_subset.coverage_axis.grid_axis.resolution * time_seconds)) / 2 low = DateTimeUtil.get_datetime_iso(low) if high is not None: high = decimal.Decimal(str(arrow.get(high).float_timestamp)) - decimal.Decimal(str(axis_subset.coverage_axis.grid_axis.resolution * time_seconds)) / 2 high = DateTimeUtil.get_datetime_iso(high) elif ConfigManager.subset_correction and high is not None and low != high and type(low) != str: # regular axes (e.g: latitude, longitude, index1d) low = decimal.Decimal(str(low)) + decimal.Decimal(str(axis_subset.coverage_axis.grid_axis.resolution)) / 2 if high is not None: high = decimal.Decimal(str(high)) - decimal.Decimal(str(axis_subset.coverage_axis.grid_axis.resolution)) / 2 subsets.append(WCSTSubset(axis_subset.coverage_axis.axis.label, low, high)) return subsets
def _translate_decimal_to_datetime(self, user_axis, geo_axis): """ DateTime axis must be translated from seconds to ISO format :param User_Axis user_axis: the dateTime user axis which needs to be translated :param Regular/Irregular geo_axis: the dateTime axis which needs to be translated """ if user_axis.type == UserAxisType.DATE: geo_axis.origin = DateTimeUtil.get_datetime_iso(geo_axis.origin) geo_axis.low = DateTimeUtil.get_datetime_iso(geo_axis.low) if geo_axis.high is not None: geo_axis.high = DateTimeUtil.get_datetime_iso(geo_axis.high) user_axis.interval.low = DateTimeUtil.get_datetime_iso(user_axis.interval.low) if user_axis.interval.high is not None: user_axis.interval.high = DateTimeUtil.get_datetime_iso(user_axis.interval.high)
def _evaluated_messages_to_dict(self, evaluated_messages): """ Converts a list of messages to json friendly data structure :param list[GRIBMessage] evaluated_messages: the messages to convert :rtype: list[dict] """ out_messages = [] for message in evaluated_messages: for user_axis in message.axes: # Translate time axis in to ISO date as Petascope will only parse dateTime format if user_axis.type == UserAxisType.DATE: user_axis.interval.low = DateTimeUtil.get_datetime_iso( user_axis.interval.low) if user_axis.interval.high is not None: user_axis.interval.high = DateTimeUtil.get_datetime_iso( user_axis.interval.high) out_messages.append(message.to_json()) return out_messages