Skip to content

Commit

Permalink
move lon/lat vars to area attrs
Browse files Browse the repository at this point in the history
  • Loading branch information
zxdawn committed Oct 16, 2023
1 parent 2638b3d commit a3f7e0c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
16 changes: 0 additions & 16 deletions satpy/etc/readers/emit_l1b.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,6 @@ file_types:
file_patterns: ['{sensor:4s}_{level:3s}_OBS_{product_version:s}_{start_time:%Y%m%dT%H%M%S}_{orbit:s}_{scene:s}.nc']

datasets:
lon:
name: lon
file_type: [emit_l1b_rad, emit_l1b_obs]
standard_name: longitude
units: degrees_east
nc_group: location
_FillValue: -9999.0

lat:
name: lat
file_type: [emit_l1b_rad, emit_l1b_obs]
standard_name: latitude
units: degrees_north
nc_group: location
_FillValue: -9999.0

elev:
name: elev
file_type: [emit_l1b_rad, emit_l1b_obs]
Expand Down
14 changes: 14 additions & 0 deletions satpy/readers/emit_l1b.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from datetime import datetime

import numpy as np
from pyresample.geometry import SwathDefinition
from satpy.readers.netcdf_utils import NetCDF4FileHandler
from satpy.utils import get_legacy_chunk_size

Expand All @@ -37,6 +38,7 @@ class EMITL1BFileHandler(NetCDF4FileHandler):
def __init__(self, filename, filename_info, filetype_info, *req_fhs):
"""Prepare the class for dataset reading."""
super().__init__(filename, filename_info, filetype_info)
self.area = None

self._load_bands()

Expand Down Expand Up @@ -146,4 +148,16 @@ def get_dataset(self, dataset_id, ds_info):
if file_type == "emit_l1b_obs":
dataset = dataset.sel(bands=ds_info['long_name']).rename(name)

# add area
self.get_lonlats()
dataset.attrs['area'] = self.area

return dataset

def get_lonlats(self):
"""Get lonlats."""
if self.area is None:
lons = self['location/lon']
lats = self['location/lat']
self.area = SwathDefinition(lons, lats)
self.area.name = '_'.join([self.sensor, str(self.start_time)])

0 comments on commit a3f7e0c

Please sign in to comment.