Skip to content

Commit

Permalink
Revert "Merge branch 'main' into feature-daynightcompositor"
Browse files Browse the repository at this point in the history
This reverts commit 80ed09a, reversing
changes made to 2ceb218.
  • Loading branch information
yukaribbba committed Sep 10, 2021
1 parent b294981 commit baf8501
Show file tree
Hide file tree
Showing 30 changed files with 66 additions and 523 deletions.
2 changes: 1 addition & 1 deletion doc/source/enhancements.rst
Expand Up @@ -27,7 +27,7 @@ on both ends of the scale, but these can be overridden with
method: !!python/name:satpy.enhancements.stretch
kwargs:
stretch: linear
cutoffs: [0.003, 0.005]
cutoffs: (0.003, 0.005)

.. note::

Expand Down
6 changes: 4 additions & 2 deletions satpy/composites/__init__.py
Expand Up @@ -46,10 +46,12 @@ class IncompatibleAreas(Exception):
"""Error raised upon compositing things of different shapes."""



class IncompatibleTimes(Exception):
"""Error raised upon compositing things from different times."""



def check_times(projectables):
"""Check that *projectables* have compatible times."""
times = []
Expand All @@ -72,6 +74,7 @@ def check_times(projectables):
# Is there a more gracious way to handle this ?
if np.max(times) - np.min(times) > np.timedelta64(1, 's'):
raise IncompatibleTimes

mid_time = (np.max(times) - np.min(times)) / 2 + np.min(times)
return mid_time

Expand Down Expand Up @@ -154,8 +157,7 @@ def apply_modifier_info(self, origin, destination):
def match_data_arrays(self, data_arrays):
"""Match data arrays so that they can be used together in a composite."""
self.check_geolocation(data_arrays)
new_arrays = self.drop_coordinates(data_arrays)
return list(xr.unify_chunks(*new_arrays))
return self.drop_coordinates(data_arrays)

def drop_coordinates(self, data_arrays):
"""Drop neglible non-dimensional coordinates."""
Expand Down
32 changes: 4 additions & 28 deletions satpy/etc/readers/modis_l1b.yaml
Expand Up @@ -438,52 +438,28 @@ datasets:
solar_zenith_angle:
name: solar_zenith_angle
sensor: modis
resolution:
1000:
file_type: [hdf_eos_geo, hdf_eos_data_1000m]
500:
file_type: [hdf_eos_geo]
250:
file_type: [hdf_eos_geo]
resolution: [1000, 500, 250]
coordinates: [longitude, latitude]
file_type: [hdf_eos_geo, hdf_eos_data_1000m]

solar_azimuth_angle:
name: solar_azimuth_angle
sensor: modis
resolution:
1000:
file_type: [hdf_eos_geo, hdf_eos_data_1000m]
500:
file_type: [hdf_eos_geo]
250:
file_type: [hdf_eos_geo]
resolution: [1000, 500, 250]
coordinates: [longitude, latitude]
file_type: [hdf_eos_geo, hdf_eos_data_1000m]

satellite_zenith_angle:
name: satellite_zenith_angle
sensor: modis
resolution:
1000:
file_type: [hdf_eos_geo, hdf_eos_data_1000m]
500:
file_type: [hdf_eos_geo]
250:
file_type: [hdf_eos_geo]
resolution: [1000, 500, 250]
coordinates: [longitude, latitude]
file_type: [hdf_eos_geo, hdf_eos_data_1000m]

satellite_azimuth_angle:
name: satellite_azimuth_angle
sensor: modis
resolution:
1000:
file_type: [hdf_eos_geo, hdf_eos_data_1000m]
500:
file_type: [hdf_eos_geo]
250:
file_type: [hdf_eos_geo]
resolution: [1000, 500, 250]
coordinates: [longitude, latitude]
file_type: [hdf_eos_geo, hdf_eos_data_1000m]

Expand Down
8 changes: 4 additions & 4 deletions satpy/modifiers/_crefl.py
Expand Up @@ -149,20 +149,20 @@ def _read_fill_value_from_hdf4(var, dtype):
return np.iinfo(dtype).min

def _get_data_and_angles(self, datasets, optional_datasets):
vis, angles = self._extract_angle_data_arrays(datasets, optional_datasets)
angles = self._extract_angle_data_arrays(datasets, optional_datasets)
angles = [xr.DataArray(dask_arr, dims=('y', 'x')) for dask_arr in angles]
return [vis] + angles
return [datasets[0]] + angles

def _extract_angle_data_arrays(self, datasets, optional_datasets):
all_datasets = datasets + optional_datasets
if len(all_datasets) == 1:
vis = self.match_data_arrays(datasets)[0]
return vis, self.get_angles(vis)
return self.get_angles(vis)
if len(all_datasets) == 5:
vis, *angles = self.match_data_arrays(
datasets + optional_datasets)
# get the dask array underneath
return vis, [data_arr.data for data_arr in angles]
return [data_arr.data for data_arr in angles]
raise ValueError("Not sure how to handle provided dependencies. "
"Either all 4 angles must be provided or none of "
"of them.")
Expand Down
33 changes: 2 additions & 31 deletions satpy/readers/hdfeos_base.py
Expand Up @@ -27,7 +27,7 @@
from pyhdf.error import HDF4Error
from pyhdf.SD import SD

from satpy import CHUNK_SIZE, DataID
from satpy import CHUNK_SIZE
from satpy.readers.file_handlers import BaseFileHandler

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -120,12 +120,6 @@ def read_mda(attribute):
current_dict[key] = val
return mda

@property
def metadata_platform_name(self):
"""Platform name from the internal file metadata."""
return self.metadata['INVENTORYMETADATA']['ASSOCIATEDPLATFORMINSTRUMENTSENSOR'][
'ASSOCIATEDPLATFORMINSTRUMENTSENSORCONTAINER']['ASSOCIATEDPLATFORMSHORTNAME']['VALUE']

@property
def start_time(self):
"""Get the start time of the dataset."""
Expand Down Expand Up @@ -171,33 +165,11 @@ def load_dataset(self, dataset_name):

scale_factor = data.attrs.get('scale_factor')
if scale_factor is not None:
data = data * np.float32(scale_factor)
data = data * scale_factor

data = data.where(good_mask, new_fill)
return data

def _add_satpy_metadata(self, data_id: DataID, data_arr: xr.DataArray):
"""Add metadata that is specific to Satpy."""
new_attrs = {
'platform_name': 'EOS-' + self.metadata_platform_name,
'sensor': 'modis',
}

res = data_id["resolution"]
rps = self._resolution_to_rows_per_scan(res)
new_attrs["rows_per_scan"] = rps

data_arr.attrs.update(new_attrs)

def _resolution_to_rows_per_scan(self, resolution: int) -> int:
known_rps = {
5000: 2,
1000: 10,
500: 20,
250: 40,
}
return known_rps.get(resolution, 10)


class HDFEOSGeoReader(HDFEOSBaseFileReader):
"""Handler for the geographical datasets."""
Expand Down Expand Up @@ -321,6 +293,5 @@ def get_dataset(self, dataset_keys, dataset_info):
for key in ('standard_name', 'units'):
if key in dataset_info:
data.attrs[key] = dataset_info[key]
self._add_satpy_metadata(dataset_keys, data)

return data
7 changes: 6 additions & 1 deletion satpy/readers/modis_l1b.py
Expand Up @@ -81,6 +81,12 @@ def get_dataset(self, key, info):
'EV_500_RefSB'],
250: ['EV_250_RefSB']}

platform_name = self.metadata['INVENTORYMETADATA']['ASSOCIATEDPLATFORMINSTRUMENTSENSOR'][
'ASSOCIATEDPLATFORMINSTRUMENTSENSORCONTAINER']['ASSOCIATEDPLATFORMSHORTNAME']['VALUE']

info.update({'platform_name': 'EOS-' + platform_name})
info.update({'sensor': 'modis'})

if self.resolution != key['resolution']:
return

Expand Down Expand Up @@ -175,7 +181,6 @@ def get_dataset(self, key, info):
# satscene[band].area = geometry.SwathDefinition(
# lons=satscene[band].area.lons[indices, :],
# lats=satscene[band].area.lats[indices, :])
self._add_satpy_metadata(key, projectable)
return projectable


Expand Down
1 change: 0 additions & 1 deletion satpy/readers/modis_l2.py
Expand Up @@ -163,7 +163,6 @@ def get_dataset(self, dataset_id, dataset_info):
else:
dataset = self.load_dataset(dataset_name_in_file)

self._add_satpy_metadata(dataset_id, dataset)
return dataset


Expand Down
Binary file not shown.
Binary file not shown.

0 comments on commit baf8501

Please sign in to comment.