_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 31 13.1k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q27000 | SCMIFileHandler._get_proj_specific_params | train | def _get_proj_specific_params(self, projection):
"""Convert CF projection parameters to PROJ.4 dict."""
proj = self._get_proj4_name(projection)
proj_dict = {
'proj': proj,
'a': float(projection.attrs['semi_major_axis']),
'b': float(projection.attrs['semi_minor... | python | {
"resource": ""
} |
q27001 | timecds2datetime | train | def timecds2datetime(tcds):
"""Method for converting time_cds-variables to datetime-objectsself.
Works both with a dictionary and a numpy record_array.
"""
days = int(tcds['Days'])
milliseconds = int(tcds['Milliseconds'])
try:
microseconds = int(tcds['Microseconds'])
except (KeyErro... | python | {
"resource": ""
} |
q27002 | show | train | def show(data, negate=False):
"""Show the stretched data.
"""
from PIL import Image as pil
data = np.array((data - data.min()) * 255.0 /
| python | {
"resource": ""
} |
q27003 | HRITMSGPrologueFileHandler._get_satpos_cart | train | def _get_satpos_cart(self):
"""Determine satellite position in earth-centered cartesion coordinates
The coordinates as a function of time are encoded in the coefficients of an 8th-order Chebyshev polynomial.
In the prologue there is one set of coefficients for each coordinate (x, y, z). The coo... | python | {
"resource": ""
} |
q27004 | HRITMSGPrologueFileHandler._find_navigation_coefs | train | def _find_navigation_coefs(self):
"""Find navigation coefficients for the current time
The navigation Chebyshev coefficients are only valid for a certain time interval. The header entry
SatelliteStatus/Orbit/OrbitPolynomial contains multiple coefficients for multiple time intervals. Find the
... | python | {
"resource": ""
} |
q27005 | HRITMSGPrologueFileHandler.get_earth_radii | train | def get_earth_radii(self):
"""Get earth radii from prologue
Returns:
Equatorial radius, polar radius [m]
"""
earth_model = self.prologue['GeometricProcessing']['EarthModel']
a = earth_model['EquatorialRadius'] * 1000
| python | {
"resource": ""
} |
q27006 | HRITMSGEpilogueFileHandler.read_epilogue | train | def read_epilogue(self):
"""Read the epilogue metadata."""
with open(self.filename, "rb") as fp_:
fp_.seek(self.mda['total_header_length'])
| python | {
"resource": ""
} |
q27007 | HRITMSGFileHandler._get_header | train | def _get_header(self):
"""Read the header info, and fill the metadata dictionary"""
earth_model = self.prologue['GeometricProcessing']['EarthModel']
self.mda['offset_corrected'] = earth_model['TypeOfEarthModel'] == 2
# Projection
a, b = self.prologue_.get_earth_radii()
... | python | {
"resource": ""
} |
q27008 | omerc2cf | train | def omerc2cf(area):
"""Return the cf grid mapping for the omerc projection."""
proj_dict = area.proj_dict
args = dict(azimuth_of_central_line=proj_dict.get('alpha'),
latitude_of_projection_origin=proj_dict.get('lat_0'),
longitude_of_projection_origin=proj_dict.get('lonc'),
... | python | {
"resource": ""
} |
q27009 | geos2cf | train | def geos2cf(area):
"""Return the cf grid mapping for the geos projection."""
proj_dict = area.proj_dict
args = dict(perspective_point_height=proj_dict.get('h'),
latitude_of_projection_origin=proj_dict.get('lat_0'),
longitude_of_projection_origin=proj_dict.get('lon_0'),
... | python | {
"resource": ""
} |
q27010 | laea2cf | train | def laea2cf(area):
"""Return the cf grid mapping for the laea projection."""
proj_dict = area.proj_dict
args = dict(latitude_of_projection_origin=proj_dict.get('lat_0'),
| python | {
"resource": ""
} |
q27011 | create_grid_mapping | train | def create_grid_mapping(area):
"""Create the grid mapping instance for `area`."""
try:
grid_mapping = mappings[area.proj_dict['proj']](area)
| python | {
"resource": ""
} |
q27012 | area2lonlat | train | def area2lonlat(dataarray):
"""Convert an area to longitudes and latitudes."""
area = dataarray.attrs['area']
lons, lats = area.get_lonlats_dask()
lons = xr.DataArray(lons, dims=['y', 'x'],
attrs={'name': "longitude",
'standard_name': "longitude",
... | python | {
"resource": ""
} |
q27013 | CFWriter.da2cf | train | def da2cf(dataarray, epoch=EPOCH):
"""Convert the dataarray to something cf-compatible."""
new_data = dataarray.copy()
# Remove the area
new_data.attrs.pop('area', None)
anc = [ds.attrs['name']
for ds in new_data.attrs.get('ancillary_variables', [])]
if a... | python | {
"resource": ""
} |
q27014 | HRITJMAFileHandler._get_platform | train | def _get_platform(self):
"""Get the platform name
The platform is not specified explicitly in JMA HRIT files. For
segmented data it is not even specified in the filename. But it
can be derived indirectly from the projection name:
GEOS(140.00): MTSAT-1R
GEOS(140.... | python | {
"resource": ""
} |
q27015 | HRITJMAFileHandler._check_sensor_platform_consistency | train | def _check_sensor_platform_consistency(self, sensor):
"""Make sure sensor and platform are consistent
Args:
sensor (str) : Sensor name from YAML dataset definition
Raises:
ValueError if they don't match
"""
ref_sensor = SENSORS.get(self.platform, None)
... | python | {
"resource": ""
} |
q27016 | HRITJMAFileHandler._get_line_offset | train | def _get_line_offset(self):
"""Get line offset for the current segment
Read line offset from the file and adapt it to the current segment
or half disk scan so that
y(l) ~ l - loff
because this is what get_geostationary_area_extent() expects.
"""
# Get line ... | python | {
"resource": ""
} |
q27017 | HRITJMAFileHandler._mask_space | train | def _mask_space(self, data):
"""Mask space pixels"""
geomask | python | {
"resource": ""
} |
q27018 | BaseFileHandler.combine_info | train | def combine_info(self, all_infos):
"""Combine metadata for multiple datasets.
When loading data from multiple files it can be non-trivial to combine
things like start_time, end_time, start_orbit, end_orbit, etc.
By default this method will produce a dictionary containing all values
... | python | {
"resource": ""
} |
q27019 | get_available_channels | train | def get_available_channels(header):
"""Get the available channels from the header information"""
chlist_str = header['15_SECONDARY_PRODUCT_HEADER'][
'SelectedBandIDs']['Value']
retv = {}
| python | {
"resource": ""
} |
q27020 | NativeMSGFileHandler._get_data_dtype | train | def _get_data_dtype(self):
"""Get the dtype of the file based on the actual available channels"""
pkhrec = [
('GP_PK_HEADER', GSDTRecords.gp_pk_header),
('GP_PK_SH1', GSDTRecords.gp_pk_sh1)
]
pk_head_dtype = np.dtype(pkhrec)
def get_lrec(cols):
... | python | {
"resource": ""
} |
q27021 | NativeMSGFileHandler._get_memmap | train | def _get_memmap(self):
"""Get the memory map for the SEVIRI data"""
with open(self.filename) as fp:
data_dtype = self._get_data_dtype()
hdr_size = native_header.itemsize
return np.memmap(fp, dtype=data_dtype,
| python | {
"resource": ""
} |
q27022 | NativeMSGFileHandler._read_header | train | def _read_header(self):
"""Read the header info"""
data = np.fromfile(self.filename,
dtype=native_header, count=1)
self.header.update(recarray2dict(data))
data15hd = self.header['15_DATA_HEADER']
sec15hd = self.header['15_SECONDARY_PRODUCT_HEADER']
... | python | {
"resource": ""
} |
q27023 | radiance_to_bt | train | def radiance_to_bt(arr, wc_, a__, b__):
"""Convert to BT. | python | {
"resource": ""
} |
q27024 | EPSAVHRRFile.keys | train | def keys(self):
"""List of reader's keys.
"""
keys = []
for val in self.form.scales.values():
| python | {
"resource": ""
} |
q27025 | GHRSST_OSISAFL2.get_lonlats | train | def get_lonlats(self, navid, nav_info, lon_out=None, lat_out=None):
"""Load an area.
"""
lon_key = 'lon'
valid_min = self[lon_key + '/attr/valid_min']
valid_max = self[lon_key + '/attr/valid_max']
lon_out.data[:] = self[lon_key][::-1]
lon_out.mask[:] = (lon_out <... | python | {
"resource": ""
} |
q27026 | _vis_calibrate | train | def _vis_calibrate(data,
chn,
calib_type,
pre_launch_coeffs=False,
calib_coeffs=None,
mask=False):
"""Visible channel calibration only.
*calib_type* in count, reflectance, radiance
"""
# Calibration count to ... | python | {
"resource": ""
} |
q27027 | AVHRRAAPPL1BFile.get_angles | train | def get_angles(self, angle_id):
"""Get sun-satellite viewing angles"""
tic = datetime.now()
sunz40km = self._data["ang"][:, :, 0] * 1e-2
satz40km = self._data["ang"][:, :, 1] * 1e-2
azidiff40km = self._data["ang"][:, :, 2] * 1e-2
try:
from geotiepoints.inte... | python | {
"resource": ""
} |
q27028 | AVHRRAAPPL1BFile.navigate | train | def navigate(self):
"""Return the longitudes and latitudes of the scene.
"""
tic = datetime.now()
lons40km = self._data["pos"][:, :, 1] * 1e-4
lats40km = self._data["pos"][:, :, 0] * 1e-4
try:
from geotiepoints import SatelliteInterpolator
except Impo... | python | {
"resource": ""
} |
q27029 | NetCDF4FileHandler._collect_attrs | train | def _collect_attrs(self, name, obj):
"""Collect all the attributes for the provided file object.
"""
for key in obj.ncattrs():
value = getattr(obj, key)
fc_key = "{}/attr/{}".format(name, key)
| python | {
"resource": ""
} |
q27030 | NetCDF4FileHandler.collect_metadata | train | def collect_metadata(self, name, obj):
"""Collect all file variables and attributes for the provided file object.
This method also iterates through subgroups of the provided object.
"""
# Look through each subgroup
base_name = name + "/" if name else ""
for group_name, g... | python | {
"resource": ""
} |
q27031 | ACSPOFileHandler.get_dataset | train | def get_dataset(self, dataset_id, ds_info, xslice=slice(None), yslice=slice(None)):
"""Load data array and metadata from file on disk."""
var_path = ds_info.get('file_key', '{}'.format(dataset_id.name))
metadata = self.get_metadata(dataset_id, ds_info)
shape = metadata['shape']
f... | python | {
"resource": ""
} |
q27032 | VIIRSActiveFiresFileHandler.get_dataset | train | def get_dataset(self, dsid, dsinfo):
"""Get dataset function
Args:
dsid: Dataset ID
param2: Dataset Information
Returns:
Dask DataArray: Data
"""
data = self[dsinfo.get('file_key', dsid.name)]
data.attrs.update(dsinfo)
| python | {
"resource": ""
} |
q27033 | np2str | train | def np2str(value):
"""Convert an `numpy.string_` to str.
Args:
value (ndarray): scalar or 1-element numpy array to convert
Raises:
ValueError: if value is array larger than 1-element or it is not of
type `numpy.string_` or it is not a numpy array
"""
if | python | {
"resource": ""
} |
q27034 | get_geostationary_mask | train | def get_geostationary_mask(area):
"""Compute a mask of the earth's shape as seen by a geostationary satellite
Args:
area (pyresample.geometry.AreaDefinition) : Corresponding area
definition
Returns:
Boolean mask, True inside the earth's s... | python | {
"resource": ""
} |
q27035 | _lonlat_from_geos_angle | train | def _lonlat_from_geos_angle(x, y, geos_area):
"""Get lons and lats from x, y in projection coordinates."""
h = (geos_area.proj_dict['h'] + geos_area.proj_dict['a']) / 1000
b__ = (geos_area.proj_dict['a'] / geos_area.proj_dict['b']) ** 2
sd = np.sqrt((h * np.cos(x) * np.cos(y)) ** 2 -
(... | python | {
"resource": ""
} |
q27036 | get_sub_area | train | def get_sub_area(area, xslice, yslice):
"""Apply slices to the area_extent and size of the area."""
new_area_extent = ((area.pixel_upper_left[0] +
(xslice.start - 0.5) * area.pixel_size_x),
(area.pixel_upper_left[1] -
(yslice.stop - 0.5) * a... | python | {
"resource": ""
} |
q27037 | unzip_file | train | def unzip_file(filename):
"""Unzip the file if file is bzipped = ending with 'bz2'"""
if filename.endswith('bz2'):
bz2file = bz2.BZ2File(filename)
fdn, tmpfilepath = tempfile.mkstemp()
with closing(os.fdopen(fdn, 'wb')) as ofpt:
try:
ofpt.write(bz2file.read()... | python | {
"resource": ""
} |
q27038 | bbox | train | def bbox(img):
"""Find the bounding box around nonzero elements in the given array
Copied from https://stackoverflow.com/a/31402351/5703449 .
Returns:
rowmin, rowmax, colmin, colmax
"""
rows = np.any(img, axis=1)
cols = np.any(img, axis=0)
| python | {
"resource": ""
} |
q27039 | Scene._compute_metadata_from_readers | train | def _compute_metadata_from_readers(self):
"""Determine pieces of metadata from the readers loaded."""
mda = {'sensor': self._get_sensor_names()}
# overwrite the request start/end times with actual loaded data | python | {
"resource": ""
} |
q27040 | Scene._get_sensor_names | train | def _get_sensor_names(self):
"""Join the sensors from all loaded readers."""
# if the user didn't tell us what sensors to work with, let's figure it
# out
if not self.attrs.get('sensor'):
# reader finder could return multiple readers
return set([sensor for reader_... | python | {
"resource": ""
} |
q27041 | Scene.create_reader_instances | train | def create_reader_instances(self,
filenames=None,
reader=None,
reader_kwargs=None):
"""Find readers and return their instances."""
return load_readers(filenames=filenames,
| python | {
"resource": ""
} |
q27042 | Scene._compare_areas | train | def _compare_areas(self, datasets=None, compare_func=max):
"""Get for the provided datasets.
Args:
datasets (iterable): Datasets whose areas will be compared. Can
be either `xarray.DataArray` objects or
identifiers to get th... | python | {
"resource": ""
} |
q27043 | Scene.available_dataset_names | train | def available_dataset_names(self, reader_name=None, composites=False):
"""Get the list of the names of | python | {
"resource": ""
} |
q27044 | Scene.all_dataset_ids | train | def all_dataset_ids(self, reader_name=None, composites=False):
"""Get names of all datasets from loaded readers or `reader_name` if
specified..
:return: list of all dataset names
"""
try:
if reader_name:
readers = [self.readers[reader_name]]
... | python | {
"resource": ""
} |
q27045 | Scene.available_composite_ids | train | def available_composite_ids(self, available_datasets=None):
"""Get names of compositors that can be generated from the available datasets.
Returns: generator of available compositor's names
"""
if available_datasets is None:
available_datasets = self.available_dataset_ids(co... | python | {
"resource": ""
} |
q27046 | Scene.available_composite_names | train | def available_composite_names(self, available_datasets=None):
"""All configured composites known | python | {
"resource": ""
} |
q27047 | Scene.all_composite_ids | train | def all_composite_ids(self, sensor_names=None):
"""Get all composite IDs that are configured.
Returns: generator of configured composite names
"""
if sensor_names is None:
sensor_names = self.attrs['sensor']
compositors = []
# Note if we get compositors from ... | python | {
"resource": ""
} |
q27048 | Scene.iter_by_area | train | def iter_by_area(self):
"""Generate datasets grouped by Area.
:return: generator of (area_obj, list of dataset objects)
"""
datasets_by_area = {}
for ds in self:
a = ds.attrs.get('area')
| python | {
"resource": ""
} |
q27049 | Scene.copy | train | def copy(self, datasets=None):
"""Create a copy of the Scene including dependency information.
Args:
datasets (list, tuple): `DatasetID` objects for the datasets
to include in the new Scene object.
"""
new_scn = self.__class__()
n... | python | {
"resource": ""
} |
q27050 | Scene.all_same_area | train | def all_same_area(self):
"""All contained data arrays are on the same area."""
all_areas = [x.attrs.get('area', None) for x in self.values()]
all_areas = [x for x | python | {
"resource": ""
} |
q27051 | Scene.all_same_proj | train | def all_same_proj(self):
"""All contained data array are in the same projection."""
all_areas = [x.attrs.get('area', None) for x in self.values()]
all_areas = [x for x | python | {
"resource": ""
} |
q27052 | Scene._slice_area_from_bbox | train | def _slice_area_from_bbox(self, src_area, dst_area, ll_bbox=None,
xy_bbox=None):
"""Slice the provided area using the bounds provided."""
if ll_bbox is not None:
dst_area = AreaDefinition(
'crop_area', 'crop_area', 'crop_latlong',
... | python | {
"resource": ""
} |
q27053 | Scene._slice_datasets | train | def _slice_datasets(self, dataset_ids, slice_key, new_area, area_only=True):
"""Slice scene in-place for the datasets specified."""
new_datasets = {}
datasets = (self[ds_id] for ds_id in dataset_ids)
for ds, parent_ds in dataset_walker(datasets):
ds_id = DatasetID.from_dict(d... | python | {
"resource": ""
} |
q27054 | Scene.slice | train | def slice(self, key):
"""Slice Scene by dataset index.
.. note::
DataArrays that do not have an ``area`` attribute will not be
sliced.
"""
if not self.all_same_area:
raise RuntimeError("'Scene' has different areas and cannot "
... | python | {
"resource": ""
} |
q27055 | Scene.crop | train | def crop(self, area=None, ll_bbox=None, xy_bbox=None, dataset_ids=None):
"""Crop Scene to a specific Area boundary or bounding box.
Args:
area (AreaDefinition): Area to crop the current Scene to
ll_bbox (tuple, list): 4-element tuple where values are in
... | python | {
"resource": ""
} |
q27056 | Scene.aggregate | train | def aggregate(self, dataset_ids=None, boundary='exact', side='left', func='mean', **dim_kwargs):
"""Create an aggregated version of the Scene.
Args:
dataset_ids (iterable): DatasetIDs to include in the returned
`Scene`. Defaults to all datasets.
... | python | {
"resource": ""
} |
q27057 | Scene._read_datasets | train | def _read_datasets(self, dataset_nodes, **kwargs):
"""Read the given datasets from file."""
# Sort requested datasets by reader
reader_datasets = {}
for node in dataset_nodes:
ds_id = node.name
# if we already have this node loaded or the node was assigned
... | python | {
"resource": ""
} |
q27058 | Scene._get_prereq_datasets | train | def _get_prereq_datasets(self, comp_id, prereq_nodes, keepables, skip=False):
"""Get a composite's prerequisites, generating them if needed.
Args:
comp_id (DatasetID): DatasetID for the composite whose
prerequisites are being collected.
prereq_no... | python | {
"resource": ""
} |
q27059 | Scene._generate_composite | train | def _generate_composite(self, comp_node, keepables):
"""Collect all composite prereqs and create the specified composite.
Args:
comp_node (Node): Composite Node to generate a Dataset for
keepables (set): `set` to update if any datasets are needed
whe... | python | {
"resource": ""
} |
q27060 | Scene.read | train | def read(self, nodes=None, **kwargs):
"""Load datasets from the necessary reader.
Args:
nodes (iterable): DependencyTree Node objects
**kwargs: Keyword arguments to pass to the reader's `load` | python | {
"resource": ""
} |
q27061 | Scene.generate_composites | train | def generate_composites(self, nodes=None):
"""Compute all the composites contained in `requirements`.
"""
if nodes is None:
required_nodes = self.wishlist - set(self.datasets.keys())
| python | {
"resource": ""
} |
q27062 | Scene.unload | train | def unload(self, keepables=None):
"""Unload all unneeded datasets.
Datasets are considered unneeded if they weren't directly requested
or added to the Scene by the user or they are no longer needed to
generate composites that have yet to be generated.
Args:
keepable... | python | {
"resource": ""
} |
q27063 | Scene.load | train | def load(self, wishlist, calibration=None, resolution=None,
polarization=None, level=None, generate=True, unload=True,
**kwargs):
"""Read and generate requested datasets.
When the `wishlist` contains `DatasetID` objects they can either be
fully-specified `DatasetID` ob... | python | {
"resource": ""
} |
q27064 | Scene._slice_data | train | def _slice_data(self, source_area, slices, dataset):
"""Slice the data to reduce it."""
slice_x, slice_y = slices
dataset = dataset.isel(x=slice_x, y=slice_y)
assert ('x', source_area.x_size) in dataset.sizes.items()
| python | {
"resource": ""
} |
q27065 | Scene._resampled_scene | train | def _resampled_scene(self, new_scn, destination_area, reduce_data=True,
**resample_kwargs):
"""Resample `datasets` to the `destination` area.
If data reduction is enabled, some local caching is perfomed in order to
avoid recomputation of area intersections."""
n... | python | {
"resource": ""
} |
q27066 | Scene.resample | train | def resample(self, destination=None, datasets=None, generate=True,
unload=True, resampler=None, reduce_data=True,
**resample_kwargs):
"""Resample datasets and return a new scene.
Args:
destination (AreaDefinition, GridDefinition): area definition to
... | python | {
"resource": ""
} |
q27067 | Scene.to_geoviews | train | def to_geoviews(self, gvtype=None, datasets=None, kdims=None, vdims=None, dynamic=False):
"""Convert satpy Scene to geoviews.
Args:
gvtype (gv plot type):
One of gv.Image, gv.LineContours, gv.FilledContours, gv.Points
Default to :class:`geoviews.Image`.
... | python | {
"resource": ""
} |
q27068 | Scene.to_xarray_dataset | train | def to_xarray_dataset(self, datasets=None):
"""Merge all xr.DataArrays of a scene to a xr.DataSet.
Parameters:
datasets (list):
List of products to include in the :class:`xarray.Dataset`
Returns: :class:`xarray.Dataset`
"""
if datasets is not None:
... | python | {
"resource": ""
} |
q27069 | Scene.images | train | def images(self):
"""Generate images for all the datasets from the scene."""
for ds_id, projectable in self.datasets.items():
| python | {
"resource": ""
} |
q27070 | dictify | train | def dictify(r, root=True):
"""Convert an ElementTree into a dict."""
if root:
return {r.tag: dictify(r, False)}
d = {}
if r.text and r.text.strip():
try:
return int(r.text)
except ValueError:
try:
return float(r.text)
except Val... | python | {
"resource": ""
} |
q27071 | interpolate_slice | train | def interpolate_slice(slice_rows, slice_cols, interpolator):
"""Interpolate the given slice of the larger array."""
fine_rows = np.arange(slice_rows.start, slice_rows.stop, slice_rows.step)
fine_cols | python | {
"resource": ""
} |
q27072 | interpolate_xarray | train | def interpolate_xarray(xpoints, ypoints, values, shape, kind='cubic',
blocksize=CHUNK_SIZE):
"""Interpolate, generating a dask array."""
vchunks = range(0, shape[0], blocksize)
hchunks = range(0, shape[1], blocksize)
token = tokenize(blocksize, xpoints, ypoints, values, kind, sha... | python | {
"resource": ""
} |
q27073 | interpolate_xarray_linear | train | def interpolate_xarray_linear(xpoints, ypoints, values, shape, chunks=CHUNK_SIZE):
"""Interpolate linearly, generating a dask array."""
from scipy.interpolate.interpnd import (LinearNDInterpolator,
_ndim_coords_from_arrays)
if isinstance(chunks, (list, tuple)):
... | python | {
"resource": ""
} |
q27074 | SAFEXML.read_azimuth_noise_array | train | def read_azimuth_noise_array(elts):
"""Read the azimuth noise vectors.
The azimuth noise is normalized per swath to account for gain
differences between the swaths in EW mode.
This is based on the this reference:
J. Park, A. A. Korosov, M. Babiker, S. Sandven and J. Won,
... | python | {
"resource": ""
} |
q27075 | SAFEXML.interpolate_xml_array | train | def interpolate_xml_array(data, low_res_coords, shape, chunks):
"""Interpolate arbitrary size dataset to a full sized grid."""
xpoints, ypoints = low_res_coords
| python | {
"resource": ""
} |
q27076 | SAFEXML.get_noise_correction | train | def get_noise_correction(self, shape, chunks=None):
"""Get the noise correction array."""
data_items = self.root.findall(".//noiseVector")
data, low_res_coords = self.read_xml_array(data_items, 'noiseLut')
if not data_items:
data_items = self.root.findall(".//noiseRangeVector... | python | {
"resource": ""
} |
q27077 | SAFEXML.get_calibration | train | def get_calibration(self, name, shape, chunks=None):
"""Get the calibration array."""
data_items = self.root.findall(".//calibrationVector")
data, | python | {
"resource": ""
} |
q27078 | SAFEGRD.read_band_blocks | train | def read_band_blocks(self, blocksize=CHUNK_SIZE):
"""Read the band in native blocks."""
# For sentinel 1 data, the block are 1 line, and dask seems to choke on that.
band = self.filehandle
shape = band.shape
token = tokenize(blocksize, band)
name = 'read_band-' + token
... | python | {
"resource": ""
} |
q27079 | SAFEGRD.read_band | train | def read_band(self, blocksize=CHUNK_SIZE):
"""Read the band in chunks."""
band = self.filehandle
shape = band.shape
if len(band.block_shapes) == 1:
total_size = blocksize * blocksize * 1.0
lines, cols = band.block_shapes[0]
if cols > lines:
... | python | {
"resource": ""
} |
q27080 | SAFEGRD.get_lonlatalts | train | def get_lonlatalts(self):
"""Obtain GCPs and construct latitude and longitude arrays.
Args:
band (gdal band): Measurement band which comes with GCP's
array_shape (tuple) : The size of the data array
Returns:
coordinates (tuple): A tuple with longitude and latitu... | python | {
"resource": ""
} |
q27081 | SAFEGRD.get_gcps | train | def get_gcps(self):
"""Read GCP from the GDAL band.
Args:
band (gdal band): Measurement band which comes with GCP's
coordinates (tuple): A tuple with longitude and latitude arrays
Returns:
points (tuple): Pixel and Line indices 1d arrays
gcp_coords (... | python | {
"resource": ""
} |
q27082 | VIIRSSDRFileHandler.scale_swath_data | train | def scale_swath_data(self, data, scaling_factors):
"""Scale swath data using scaling factors and offsets.
Multi-granule (a.k.a. aggregated) files will have more than the usual two values.
"""
num_grans = len(scaling_factors) // 2
gran_size = data.shape[0] // num_grans
fa... | python | {
"resource": ""
} |
q27083 | VIIRSSDRFileHandler.expand_single_values | train | def expand_single_values(var, scans):
"""Expand single valued variable to full scan lengths."""
if scans.size == 1:
return var
else:
expanded = np.repeat(var, | python | {
"resource": ""
} |
q27084 | VIIRSSDRFileHandler.get_bounding_box | train | def get_bounding_box(self):
"""Get the bounding box of this file."""
from pyproj import Geod
geod = Geod(ellps='WGS84')
dataset_group = DATASET_KEYS[self.datasets[0]]
idx = 0
lons_ring = None
lats_ring = None
while True:
path = 'Data_Products/{... | python | {
"resource": ""
} |
q27085 | VIIRSSDRReader._load_from_geo_ref | train | def _load_from_geo_ref(self, dsid):
"""Load filenames from the N_GEO_Ref attribute of a dataset's file."""
file_handlers = self._get_file_handlers(dsid)
if not file_handlers:
return None
fns = []
for fh in file_handlers:
base_dir = os.path.dirname(fh.file... | python | {
"resource": ""
} |
q27086 | VIIRSSDRReader._get_req_rem_geo | train | def _get_req_rem_geo(self, ds_info):
"""Find out which geolocation files are needed."""
if ds_info['dataset_groups'][0].startswith('GM'):
if self.use_tc is False:
req_geo = 'GMODO'
rem_geo = 'GMTCO'
else:
req_geo = 'GMTCO'
... | python | {
"resource": ""
} |
q27087 | VIIRSSDRReader._get_coordinates_for_dataset_key | train | def _get_coordinates_for_dataset_key(self, dsid):
"""Get the coordinate dataset keys for `dsid`.
Wraps the base class method in order to load geolocation files
from the geo reference attribute in the datasets file.
"""
coords = super(VIIRSSDRReader, self)._get_coordinates_for_da... | python | {
"resource": ""
} |
q27088 | GeoTIFFWriter._gdal_write_datasets | train | def _gdal_write_datasets(self, dst_ds, datasets):
"""Write datasets in a gdal raster structure dts_ds"""
for i, band in enumerate(datasets['bands']): | python | {
"resource": ""
} |
q27089 | GeoTIFFWriter.save_image | train | def save_image(self, img, filename=None, dtype=None, fill_value=None,
floating_point=None, compute=True, **kwargs):
"""Save the image to the given ``filename`` in geotiff_ format.
Note for faster output and reduced memory usage the ``rasterio``
library must be installed. This... | python | {
"resource": ""
} |
q27090 | HDF4BandReader.get_end_time | train | def get_end_time(self):
"""Get observation end time from file metadata."""
mda_dict = self.filehandle.attributes()
core_mda = mda_dict['coremetadata']
| python | {
"resource": ""
} |
q27091 | HDF4BandReader.parse_metadata_string | train | def parse_metadata_string(metadata_string):
"""Grab end time with regular expression."""
regex = r"STOP_DATE.+?VALUE\s*=\s*\"(.+?)\""
| python | {
"resource": ""
} |
q27092 | HDF4BandReader.get_filehandle | train | def get_filehandle(self):
"""Get HDF4 filehandle."""
if os.path.exists(self.filename):
self.filehandle = | python | {
"resource": ""
} |
q27093 | HDF4BandReader.get_sds_variable | train | def get_sds_variable(self, name):
"""Read variable from the HDF4 file."""
| python | {
"resource": ""
} |
q27094 | HDF4BandReader.get_lonlats | train | def get_lonlats(self):
"""Get longitude and latitude arrays from the file."""
longitudes = self.get_sds_variable('Longitude')
| python | {
"resource": ""
} |
q27095 | Node.flatten | train | def flatten(self, d=None):
"""Flatten tree structure to a one level dictionary.
Args:
d (dict, optional): output dictionary to update
Returns:
dict: Node.name -> Node. The returned | python | {
"resource": ""
} |
q27096 | Node.add_child | train | def add_child(self, obj):
"""Add a child to the node."""
| python | {
"resource": ""
} |
q27097 | Node.display | train | def display(self, previous=0, include_data=False):
"""Display the node."""
no_data = " (No Data)" if self.data is None | python | {
"resource": ""
} |
q27098 | Node.trunk | train | def trunk(self, unique=True):
"""Get the trunk of the tree starting at this root."""
# uniqueness is not correct in `trunk` yet
unique = False
res = []
if self.children:
| python | {
"resource": ""
} |
q27099 | DependencyTree.copy | train | def copy(self):
"""Copy the this node tree
Note all references to readers are removed. This is meant to avoid
tree copies accessing readers that would return incompatible (Area)
data. Theoretically it should be possible for tree copies to request
compositor or modifier informati... | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.