def save(self, start_line, end_line, output_file_prefix="PyGAC", output_dir="./", avhrr_dir=None, qual_dir=None, sunsatangles_dir=None): """Convert the Reader instance content into hdf5 files""" avhrr_dir = avhrr_dir or output_dir qual_dir = qual_dir or output_dir sunsatangles_dir = sunsatangles_dir or output_dir self.get_lonlat() channels = self._get_calibrated_channels_uniform_shape() sat_azi, sat_zen, sun_azi, sun_zen, rel_azi = self.get_angles() qual_flags = self.get_qual_flags() if (np.all(self.mask)): print("ERROR: All data is masked out. Stop processing") raise ValueError("All data is masked out.") gac_io.save_gac(self.spacecraft_name, self.utcs, self.lats, self.lons, channels[:, :, 0], channels[:, :, 1], channels[:, :, 2], channels[:, :, 3], channels[:, :, 4], channels[:, :, 5], sun_zen, sat_zen, sun_azi, sat_azi, rel_azi, qual_flags, start_line, end_line, self.filename, self.meta_data, output_file_prefix, avhrr_dir, qual_dir, sunsatangles_dir)
def main(filename, start_line, end_line): tic = datetime.datetime.now() reader = GACKLMReader() reader.read(filename) reader.get_lonlat() channels = reader.get_calibrated_channels() sat_azi, sat_zen, sun_azi, sun_zen, rel_azi = reader.get_angles() mask, qual_flags = reader.get_corrupt_mask() if (np.all(mask)): print("ERROR: All data is masked out. Stop processing") raise ValueError("All data is masked out.") gac_io.save_gac(reader.spacecraft_name, reader.utcs, reader.lats, reader.lons, channels[:, :, 0], channels[:, :, 1], channels[:, :, 2], channels[:, :, 3], channels[:, :, 4], channels[:, :, 5], sun_zen, sat_zen, sun_azi, sat_azi, rel_azi, mask, qual_flags, start_line, end_line, reader.is_tsm_affected(), reader.filename, reader.get_midnight_scanline(), reader.get_miss_lines(), reader.get_ch3_switch()) LOG.info("pygac took: %s", str(datetime.datetime.now() - tic))
def main_klm(reader_cls, filename, start_line, end_line): """Generate a l1c file.""" from pygac import gac_io tic = datetime.datetime.now() reader = reader_cls() reader.read(filename) reader.get_lonlat() channels = reader.get_calibrated_channels() sat_azi, sat_zen, sun_azi, sun_zen, rel_azi = reader.get_angles() qual_flags = reader.get_qual_flags() if (np.all(reader.mask)): print("ERROR: All data is masked out. Stop processing") raise ValueError("All data is masked out.") gac_io.save_gac(reader.spacecraft_name, reader.utcs, reader.lats, reader.lons, channels[:, :, 0], channels[:, :, 1], channels[:, :, 2], channels[:, :, 3], channels[:, :, 4], channels[:, :, 5], sun_zen, sat_zen, sun_azi, sat_azi, rel_azi, qual_flags, start_line, end_line, reader.filename, reader.meta_data) LOG.info("pygac took: %s", str(datetime.datetime.now() - tic))
def main(filename, start_line, end_line): tic = datetime.datetime.now() reader = PODReader() reader.read(filename) reader.get_lonlat() reader.adjust_clock_drift() channels = reader.get_calibrated_channels() sat_azi, sat_zen, sun_azi, sun_zen, rel_azi = reader.get_angles() mask, qual_flags = reader.get_corrupt_mask() if (np.all(mask)): print "ERROR: All data is masked out. Stop processing" raise ValueError("All data is masked out.") gac_io.save_gac(reader.spacecraft_name, reader.utcs, reader.lats, reader.lons, channels[:, :, 0], channels[:, :, 1], np.ones_like(channels[:, :, 0]) * -1, channels[:, :, 2], channels[:, :, 3], channels[:, :, 4], sun_zen, sat_zen, sun_azi, sat_azi, rel_azi, mask, qual_flags, start_line, end_line) LOG.info("pygac took: %s", str(datetime.datetime.now() - tic))
def test_save_gac(self, check_user_scanlines, slice_channel, avhrr_gac_io, strip_invalid_lat): """Test saving.""" # Test scanline selection mm = mock.MagicMock() kwargs = dict(satellite_name=mm, xutcs=mm, lats=mm, lons=mm, ref1=mm, ref2=mm, ref3=mm, bt3=mm, bt4=mm, bt5=mm, sun_zen=mm, sat_zen=mm, sun_azi=mm, sat_azi=mm, rel_azi=mm, qual_flags=mm, gac_file=mm, meta_data=mm, output_file_prefix=mm, avhrr_dir=mm, qual_dir=mm, sunsatangles_dir=mm) slice_channel.return_value = mm, 'miss', 'midnight' strip_invalid_lat.return_value = 0, 0 check_user_scanlines.return_value = 'start', 'end' gac_io.save_gac(start_line=0, end_line=0, **kwargs) slice_channel.assert_called_with(mock.ANY, start_line='start', end_line='end', first_valid_lat=mock.ANY, last_valid_lat=mock.ANY) expected_args = [ mock.ANY, mock.ANY, mock.ANY, mock.ANY, mock.ANY, mock.ANY, mock.ANY, mock.ANY, mock.ANY, mock.ANY, mock.ANY, mock.ANY, mock.ANY, mock.ANY, mock.ANY, mock.ANY, mock.ANY, mock.ANY, mock.ANY, mock.ANY, mock.ANY, mock.ANY, mock.ANY, mock.ANY, mock.ANY, mock.ANY, 'midnight', 'miss', mock.ANY, mock.ANY, mock.ANY, mock.ANY ] avhrr_gac_io.assert_called_with(*expected_args)
def main(filename, start_line, end_line): tic = datetime.datetime.now() reader = GACKLMReader() reader.read(filename) reader.get_lonlat() channels = reader.get_calibrated_channels() sat_azi, sat_zen, sun_azi, sun_zen, rel_azi = reader.get_angles() qual_flags = reader.get_qual_flags() if np.all(reader.mask): print("ERROR: All data is masked out. Stop processing") raise ValueError("All data is masked out.") gac_io.save_gac(reader.spacecraft_name, reader.utcs, reader.lats, reader.lons, channels[:, :, 0], channels[:, :, 1], channels[:, :, 2], channels[:, :, 3], channels[:, :, 4], channels[:, :, 5], sun_zen, sat_zen, sun_azi, sat_azi, rel_azi, qual_flags, start_line, end_line, reader.filename, reader.get_midnight_scanline(), reader.get_miss_lines()) LOG.info("pygac took: %s", str(datetime.datetime.now() - tic))