예제 #1
0
 def _init_time(self) -> np.ndarray:
     time = self.getvar("time")
     if max(time) > 25:
         logging.warning(
             "Assuming time as seconds, converting to fraction hour")
         time = utils.seconds2hours(time)
     return time
예제 #2
0
def _read_time_vector(nc_file: str) -> ndarray:
    """Converts time vector to fraction hour."""
    nc = netCDF4.Dataset(nc_file)
    time = nc.variables['time'][:]
    nc.close()
    if max(time) < 24:
        return time
    return utils.seconds2hours(time)
예제 #3
0
 def convert_time_to_fraction_hour(self,
                                   data_type: Optional[str] = None) -> None:
     """Converts time to fraction hour."""
     key = "time"
     fraction_hour = utils.seconds2hours(self.raw_data[key])
     self.data[key] = CloudnetArray(np.array(fraction_hour),
                                    key,
                                    data_type=data_type)
예제 #4
0
 def _convert_time(self, data: dict) -> CloudnetArray:
     seconds = []
     for timestamp in data["_time"]:
         if self.source == PARSIVEL:
             _, _, _, hour, minute, sec = _parse_parsivel_timestamp(timestamp)
         else:
             hour, minute, sec = timestamp.split(":")
         seconds.append(int(hour) * 3600 + int(minute) * 60 + int(sec))
     return CloudnetArray(utils.seconds2hours(np.array(seconds)), "time")
예제 #5
0
 def _convert_time(self):
     time = self.variables['time']
     try:
         assert all(np.diff(time) > 0)
     except AssertionError:
         raise RuntimeError('Inconsistent ceilometer time stamps.')
     if max(time) > 24:
         time = utils.seconds2hours(time)
     return time
예제 #6
0
 def __init__(self, raw_data, site_properties):
     self.raw_data = raw_data
     self.date = self._get_date()
     self.raw_data['time'] = utils.seconds2hours(self.raw_data['time'])
     self.raw_data['altitude'] = site_properties['altitude']
     self._mask_invalid_ldr()
     self.data = {}
     self._init_data()
     self.source = 'RPG-FMCW'
     self.location = site_properties['name']
예제 #7
0
 def _fetch_time(self) -> np.ndarray:
     time = self.variables['time'][:]
     ind = time.argsort()
     time = time[ind]
     self.backscatter = self.backscatter[ind, :]
     if self._expected_date is not None:
         epoch = utils.get_epoch(self.variables['time'].units)
         valid_ind = []
         for ind, timestamp in enumerate(time):
             date = '-'.join(utils.seconds2date(timestamp, epoch)[:3])
             if date == self._expected_date:
                 valid_ind.append(ind)
         if not valid_ind:
             raise ValueError('Error: CHM15k date differs from expected.')
         time = time[valid_ind]
         self.backscatter = self.backscatter[valid_ind, :]
     return utils.seconds2hours(time)
예제 #8
0
def test_seconds2hours(input, output):
    assert utils.seconds2hours(input) == output
예제 #9
0
 def get_date_and_time(self, epoch: Epoch) -> None:
     if self.expected_date is not None:
         self.data = utils.screen_by_time(self.data, epoch,
                                          self.expected_date)
     self.date = utils.seconds2date(self.data["time"][0], epoch=epoch)[:3]
     self.data["time"] = utils.seconds2hours(self.data["time"])
예제 #10
0
 def convert_time_to_fraction_hour(self) -> None:
     """Converts time to fraction hour."""
     key = 'time'
     fraction_hour = utils.seconds2hours(self.raw_data[key])
     self.raw_data[key] = fraction_hour
     self.data[key] = CloudnetArray(np.array(fraction_hour), key)
예제 #11
0
 def _init_time(self) -> np.ndarray:
     time = self.getvar('time')
     if max(time) > 25:
         time = utils.seconds2hours(time)
     return time