Code stringlengths 103 85.9k | Summary listlengths 0 94 |
|---|---|
Please provide a description of the function:def _get_tile_when_web_mercator_crs(self, x_tile, y_tile, zoom,
bands=None, masked=None,
resampling=Resampling.cubic):
roi = GeoVector.from_xyz(x_tile, y_tile, zoom)
coor... | [
" The reason we want to treat this case in a special way\n is that there are cases where the rater is aligned so you need to be precise\n on which raster you want\n "
] |
Please provide a description of the function:def get_tile(self, x_tile, y_tile, zoom,
bands=None, masked=None, resampling=Resampling.cubic):
if self.crs == WEB_MERCATOR_CRS:
return self._get_tile_when_web_mercator_crs(x_tile, y_tile, zoom, bands, masked, resampling)
... | [
"Convert mercator tile to raster window.\n\n :param x_tile: x coordinate of tile\n :param y_tile: y coordinate of tile\n :param zoom: zoom level\n :param bands: list of indices of requested bands, default None which returns all bands\n :param resampling: reprojection resampling me... |
Please provide a description of the function:def colorize(self, colormap, band_name=None, vmin=None, vmax=None):
vmin = vmin if vmin is not None else min(self.min())
vmax = vmax if vmax is not None else max(self.max())
cmap = matplotlib.cm.get_cmap(colormap) # type: matplotlib.colors.... | [
"Apply a colormap on a selected band.\n\n colormap list: https://matplotlib.org/examples/color/colormaps_reference.html\n\n Parameters\n ----------\n colormap : str\n Colormap name from this list https://matplotlib.org/examples/color/colormaps_reference.html\n\n band_name :... |
Please provide a description of the function:def chunks(self, shape=256, pad=False):
_self = self._raster_backed_by_a_file()
if isinstance(shape, int):
shape = (shape, shape)
(width, height) = shape
col_steps = int(_self.width / width)
row_steps = int(_self... | [
"This method returns GeoRaster chunks out of the original raster.\n\n The chunck is evaluated only when fetched from the iterator.\n Useful when you want to iterate over a big rasters.\n\n Parameters\n ----------\n shape : int or tuple, optional\n The shape of the chunk... |
Please provide a description of the function:def dissolve(collection, aggfunc=None):
# type: (BaseCollection, Optional[Callable[[list], Any]]) -> GeoFeature
new_properties = {}
if aggfunc:
temp_properties = defaultdict(list) # type: DefaultDict[Any, Any]
for feature in collection:
... | [
"Dissolves features contained in a FeatureCollection and applies an aggregation\n function to its properties.\n\n "
] |
Please provide a description of the function:def filter(self, intersects):
try:
crs = self.crs
vector = intersects.geometry if isinstance(intersects, GeoFeature) else intersects
prepared_shape = prep(vector.get_shape(crs))
hits = []
for featu... | [
"Filter results that intersect a given GeoFeature or Vector.\n\n "
] |
Please provide a description of the function:def sort(self, by, desc=False):
if callable(by):
key = by
else:
def key(feature):
return feature[by]
sorted_features = sorted(list(self), reverse=desc, key=key)
return self.__class__(sorted_fea... | [
"Sorts by given property or function, ascending or descending order.\n\n Parameters\n ----------\n by : str or callable\n If string, property by which to sort.\n If callable, it should receive a GeoFeature a return a value by which to sort.\n desc : bool, optional\n... |
Please provide a description of the function:def groupby(self, by):
# type: (Union[str, Callable[[GeoFeature], str]]) -> _CollectionGroupBy
results = OrderedDict() # type: OrderedDict[str, list]
for feature in self:
if callable(by):
value = by(feature)
... | [
"Groups collection using a value of a property.\n\n Parameters\n ----------\n by : str or callable\n If string, name of the property by which to group.\n If callable, should receive a GeoFeature and return the category.\n\n Returns\n -------\n _Collect... |
Please provide a description of the function:def dissolve(self, by=None, aggfunc=None):
# type: (Optional[str], Optional[Callable]) -> FeatureCollection
if by:
agg = partial(dissolve, aggfunc=aggfunc) # type: Callable[[BaseCollection], GeoFeature]
return self.groupby(by... | [
"Dissolve geometries and rasters within `groupby`.\n\n "
] |
Please provide a description of the function:def rasterize(self, dest_resolution, *, polygonize_width=0, crs=WEB_MERCATOR_CRS, fill_value=None,
bounds=None, dtype=None, **polygonize_kwargs):
# Avoid circular imports
from telluric.georaster import merge_all, MergeStrategy
... | [
"Binarize a FeatureCollection and produce a raster with the target resolution.\n\n Parameters\n ----------\n dest_resolution: float\n Resolution in units of the CRS.\n polygonize_width : int, optional\n Width for the polygonized features (lines and points) in pixels... |
Please provide a description of the function:def save(self, filename, driver=None, schema=None):
if driver is None:
driver = DRIVERS.get(os.path.splitext(filename)[-1])
if schema is None:
schema = self.schema
if driver == "GeoJSON":
# Workaround for... | [
"Saves collection to file.\n\n "
] |
Please provide a description of the function:def apply(self, **kwargs):
def _apply(f):
properties = copy.deepcopy(f.properties)
for prop, value in kwargs.items():
if callable(value):
properties[prop] = value(f)
else:
... | [
"Return a new FeatureCollection with the results of applying the statements in the arguments to each element.\n\n "
] |
Please provide a description of the function:def validate(self):
if self._schema is not None:
with MemoryFile() as memfile:
with memfile.open(driver="ESRI Shapefile", schema=self.schema) as target:
for _item in self._results:
# get... | [
"\n if schema exists we run shape file validation code of fiona by trying to save to in MemoryFile\n "
] |
Please provide a description of the function:def open(cls, filename, crs=None):
with fiona.Env():
with fiona.open(filename, 'r') as source:
original_crs = CRS(source.crs)
schema = source.schema
length = len(source)
crs = crs or origina... | [
"Creates a FileCollection from a file in disk.\n\n Parameters\n ----------\n filename : str\n Path of the file to read.\n crs : CRS\n overrides the crs of the collection, this funtion will not reprojects\n\n "
] |
Please provide a description of the function:def filter(self, func):
# type: (Callable[[BaseCollection], bool]) -> _CollectionGroupBy
results = OrderedDict() # type: OrderedDict
for name, group in self:
if func(group):
results[name] = group
return s... | [
"Filter out Groups based on filtering function.\n\n The function should get a FeatureCollection and return True to leave in the Group and False to take it out.\n "
] |
Please provide a description of the function:def prettify(elem):
rough_string = ET.tostring(elem, 'utf-8')
reparsed = minidom.parseString(rough_string)
return reparsed.toprettyxml(indent="\t") | [
"Return a pretty-printed XML string for the Element.\n "
] |
Please provide a description of the function:def reset_context(**options):
local_context._options = {}
local_context._options.update(options)
log.debug("New TelluricContext context %r created", local_context._options) | [
"Reset context to default."
] |
Please provide a description of the function:def get_context():
if not local_context._options:
raise TelluricContextError("TelluricContext context not exists")
else:
log.debug("Got a copy of context %r options", local_context._options)
return local_context._options.copy() | [
"Get a mapping of current options."
] |
Please provide a description of the function:def set_context(**options):
if not local_context._options:
raise TelluricContextError("TelluricContext context not exists")
else:
local_context._options.update(options)
log.debug("Updated existing %r with options %r", local_context._optio... | [
"Set options in the existing context."
] |
Please provide a description of the function:def from_defaults(cls, **kwargs):
options = TelluricContext.default_options()
options.update(**kwargs)
return cls(**options) | [
"Create a context with default config options\n Parameters\n ----------\n kwargs : optional\n Keyword arguments for TelluricContext()\n Returns\n -------\n TelluricContext\n Notes\n -----\n The items in kwargs will be overlaid on the default ... |
Please provide a description of the function:def transform_properties(properties, schema):
new_properties = properties.copy()
for prop_value, (prop_name, prop_type) in zip(new_properties.values(), schema["properties"].items()):
if prop_value is None:
continue
elif prop_type == "... | [
"Transform properties types according to a schema.\n\n Parameters\n ----------\n properties : dict\n Properties to transform.\n schema : dict\n Fiona schema containing the types.\n\n "
] |
Please provide a description of the function:def serialize_properties(properties):
new_properties = properties.copy()
for attr_name, attr_value in new_properties.items():
if isinstance(attr_value, datetime):
new_properties[attr_name] = attr_value.isoformat()
elif not isinstance(... | [
"Serialize properties.\n\n Parameters\n ----------\n properties : dict\n Properties to serialize.\n\n "
] |
Please provide a description of the function:def from_record(cls, record, crs, schema=None):
properties = cls._to_properties(record, schema)
vector = GeoVector(shape(record['geometry']), crs)
if record.get('raster'):
assets = {k: dict(type=RASTER_TYPE, product='visual', **v)... | [
"Create GeoFeature from a record."
] |
Please provide a description of the function:def copy_with(self, geometry=None, properties=None, assets=None):
def copy_assets_object(asset):
obj = asset.get("__object")
if hasattr("copy", obj):
new_obj = obj.copy()
if obj:
asset["__ob... | [
"Generate a new GeoFeature with different geometry or preperties."
] |
Please provide a description of the function:def from_raster(cls, raster, properties, product='visual'):
footprint = raster.footprint()
assets = raster.to_assets(product=product)
return cls(footprint, properties, assets) | [
"Initialize a GeoFeature object with a GeoRaster\n\n Parameters\n ----------\n raster : GeoRaster\n the raster in the feature\n properties : dict\n Properties.\n product : str\n product associated to the raster\n "
] |
Please provide a description of the function:def has_raster(self):
return any(asset.get('type') == RASTER_TYPE for asset in self.assets.values()) | [
"True if any of the assets is type 'raster'."
] |
Please provide a description of the function:def raster(self, name=None, **creteria):
if name:
asset = self.assets[name]
if asset["type"] in raster_types:
__object = asset.get('__object')
if isinstance(__object, GeoRaster2):
re... | [
"Generates a GeoRaster2 object based on the asset name(key) or a creteria(protety name and value)."
] |
Please provide a description of the function:def wms_vrt(wms_file, bounds=None, resolution=None):
from telluric import rasterization, constants
wms_tree = ET.parse(wms_file)
service = wms_tree.find(".//Service")
if service is not None:
service_name = service.attrib.get("name")
else:
... | [
"Make a VRT XML document from a wms file.\n Parameters\n ----------\n wms_file : str\n The source wms file\n bounds : GeoVector, optional\n The requested footprint of the generated VRT\n resolution : float, optional\n The requested resolution of the generated VRT\n Returns\n ... |
Please provide a description of the function:def boundless_vrt_doc(
src_dataset, nodata=None, background=None, hidenodata=False,
width=None, height=None, transform=None, bands=None):
nodata = nodata or src_dataset.nodata
width = width or src_dataset.width
height = height or src_dataset... | [
"Make a VRT XML document.\n Parameters\n ----------\n src_dataset : Dataset\n The dataset to wrap.\n background : Dataset, optional\n A dataset that provides the optional VRT background. NB: this dataset\n must have the same number of bands as the src_dataset.\n Returns\n ----... |
Please provide a description of the function:def raster_list_vrt(rasters, relative_to_vrt=True, nodata=None, mask_band=None):
from telluric import FeatureCollection
fc = FeatureCollection.from_georasters(rasters)
return raster_collection_vrt(fc, relative_to_vrt, nodata, mask_band) | [
"Make a VRT XML document from a list of GeoRaster2 objects.\n Parameters\n ----------\n rasters : list\n The list of GeoRasters.\n relative_to_vrt : bool, optional\n If True the bands simple source url will be related to the VRT file\n nodata : int, optional\n If supplied is the ... |
Please provide a description of the function:def raster_collection_vrt(fc, relative_to_vrt=True, nodata=None, mask_band=None):
def max_resolution():
max_affine = max(fc, key=lambda f: f.raster().resolution()).raster().affine
return abs(max_affine.a), abs(max_affine.e)
from telluric import... | [
"Make a VRT XML document from a feature collection of GeoRaster2 objects.\n Parameters\n ----------\n rasters : FeatureCollection\n The FeatureCollection of GeoRasters.\n relative_to_vrt : bool, optional\n If True the bands simple source url will be related to the VRT file\n nodata : in... |
Please provide a description of the function:def transform(shape, source_crs, destination_crs=None, src_affine=None, dst_affine=None):
if destination_crs is None:
destination_crs = WGS84_CRS
if src_affine is not None:
shape = ops.transform(lambda r, q: ~src_affine * (r, q), shape)
sha... | [
"Transforms shape from one CRS to another.\n\n Parameters\n ----------\n shape : shapely.geometry.base.BaseGeometry\n Shape to transform.\n source_crs : dict or str\n Source CRS in the form of key/value pairs or proj4 string.\n destination_crs : dict or str, optional\n Destinatio... |
Please provide a description of the function:def simple_plot(feature, *, mp=None, **map_kwargs):
# This import is here to avoid cyclic references
from telluric.collections import BaseCollection
if mp is None:
mp = folium.Map(tiles="Stamen Terrain", **map_kwargs)
if feature.is_empty:
... | [
"Plots a GeoVector in a simple Folium map.\n\n For more complex and customizable plots using Jupyter widgets,\n use the plot function instead.\n\n Parameters\n ----------\n feature : telluric.vectors.GeoVector, telluric.features.GeoFeature, telluric.collections.BaseCollection\n Data to plot.\n... |
Please provide a description of the function:def zoom_level_from_geometry(geometry, splits=4):
# This import is here to avoid cyclic references
from telluric.vectors import generate_tile_coordinates
# We split the geometry and compute the zoom level for each chunk
levels = []
for chunk in gene... | [
"Generate optimum zoom level for geometry.\n\n Notes\n -----\n The obvious solution would be\n\n >>> mercantile.bounding_tile(*geometry.get_shape(WGS84_CRS).bounds).z\n\n However, if the geometry is split between two or four tiles,\n the resulting zoom level might be too big.\n\n "
] |
Please provide a description of the function:def layer_from_element(element, style_function=None):
# This import is here to avoid cyclic references
from telluric.collections import BaseCollection
if isinstance(element, BaseCollection):
styled_element = element.map(lambda feat: style_element(fe... | [
"Return Leaflet layer from shape.\n\n Parameters\n ----------\n element : telluric.vectors.GeoVector, telluric.features.GeoFeature, telluric.collections.BaseCollection\n Data to plot.\n\n "
] |
Please provide a description of the function:def plot(feature, mp=None, style_function=None, **map_kwargs):
map_kwargs.setdefault('basemap', basemaps.Stamen.Terrain)
if feature.is_empty:
warnings.warn("The geometry is empty.")
mp = Map(**map_kwargs) if mp is None else mp
else:
... | [
"Plots a GeoVector in an ipyleaflet map.\n\n Parameters\n ----------\n feature : telluric.vectors.GeoVector, telluric.features.GeoFeature, telluric.collections.BaseCollection\n Data to plot.\n mp : ipyleaflet.Map, optional\n Map in which to plot, default to None (creates a new one).\n s... |
Please provide a description of the function:def tileserver_optimized_raster(src, dest):
src_raster = tl.GeoRaster2.open(src)
bounding_box = src_raster.footprint().get_shape(tl.constants.WGS84_CRS).bounds
tile = mercantile.bounding_tile(*bounding_box)
dest_resolution = mercator_upper_zoom_level(src... | [
" This method converts a raster to a tileserver optimized raster.\n The method will reproject the raster to align to the xyz system, in resolution and projection\n It will also create overviews\n And finally it will arragne the raster in a cog way.\n You could take the dest file upload i... |
Please provide a description of the function:def get_dimension(geometry):
coordinates = geometry["coordinates"]
type_ = geometry["type"]
if type_ in ('Point',):
return len(coordinates)
elif type_ in ('LineString', 'MultiPoint'):
return len(coordinates[0])
elif type_ in ('Polygon... | [
"Gets the dimension of a Fiona-like geometry element."
] |
Please provide a description of the function:def generate_tile_coordinates(roi, num_tiles):
# type: (GeoVector, Tuple[int, int]) -> Iterator[GeoVector]
bounds = roi.get_shape(roi.crs).bounds
x_range = np.linspace(bounds[0], bounds[2], int(num_tiles[0]) + 1)
y_range = np.linspace(bounds[1], bounds[... | [
"Yields N x M rectangular tiles for a region of interest.\n\n Parameters\n ----------\n roi : GeoVector\n Region of interest\n num_tiles : tuple\n Tuple (horizontal_tiles, vertical_tiles)\n\n Yields\n ------\n ~telluric.vectors.GeoVector\n\n "
] |
Please provide a description of the function:def generate_tile_coordinates_from_pixels(roi, scale, size):
if not all(isinstance(coord, int) for coord in size):
raise ValueError("Pixel size must be a tuple of integers")
width = size[0] * scale
height = size[1] * scale
minx, miny, maxx, max... | [
"Yields N x M rectangular tiles for a region of interest.\n\n Parameters\n ----------\n roi : GeoVector\n Region of interest\n scale : float\n Scale factor (think of it as pixel resolution)\n size : tuple\n Pixel size in (width, height) to be multiplied by the scale factor\n\n ... |
Please provide a description of the function:def from_geojson(cls, filename):
with open(filename) as fd:
geometry = json.load(fd)
if 'type' not in geometry:
raise TypeError("%s is not a valid geojson." % (filename,))
return cls(to_shape(geometry), WGS84_CRS) | [
"Load vector from geojson."
] |
Please provide a description of the function:def to_geojson(self, filename):
with open(filename, 'w') as fd:
json.dump(self.to_record(WGS84_CRS), fd) | [
"Save vector as geojson."
] |
Please provide a description of the function:def from_bounds(cls, xmin, ymin, xmax, ymax, crs=DEFAULT_CRS):
return cls(Polygon.from_bounds(xmin, ymin, xmax, ymax), crs) | [
"Creates GeoVector object from bounds.\n\n Parameters\n ----------\n xmin, ymin, xmax, ymax : float\n Bounds of the GeoVector. Also (east, south, north, west).\n crs : ~rasterio.crs.CRS, dict\n Projection, default to :py:data:`telluric.constants.DEFAULT_CRS`.\n\n ... |
Please provide a description of the function:def from_xyz(cls, x, y, z):
bb = xy_bounds(x, y, z)
return cls.from_bounds(xmin=bb.left, ymin=bb.bottom,
xmax=bb.right, ymax=bb.top,
crs=WEB_MERCATOR_CRS) | [
"Creates GeoVector from Mercator slippy map values.\n\n "
] |
Please provide a description of the function:def cascaded_union(cls, vectors, dst_crs, prevalidate=False):
# type: (list, CRS, bool) -> GeoVector
try:
shapes = [geometry.get_shape(dst_crs) for geometry in vectors]
if prevalidate:
if not all([sh.is_valid ... | [
"Generate a GeoVector from the cascade union of the impute vectors."
] |
Please provide a description of the function:def from_record(cls, record, crs):
if 'type' not in record:
raise TypeError("The data isn't a valid record.")
return cls(to_shape(record), crs) | [
"Load vector from record."
] |
Please provide a description of the function:def get_bounding_box(self, crs):
return self.from_bounds(*self.get_bounds(crs), crs=crs) | [
"Gets bounding box as GeoVector in a specified CRS."
] |
Please provide a description of the function:def equals_exact(self, other, tolerance):
# This method cannot be delegated because it has an extra parameter
return self._shape.equals_exact(other.get_shape(self.crs), tolerance=tolerance) | [
" invariant to crs. "
] |
Please provide a description of the function:def almost_equals(self, other, decimal=6):
# This method cannot be delegated because it has an extra parameter
return self._shape.almost_equals(other.get_shape(self.crs), decimal=decimal) | [
" invariant to crs. "
] |
Please provide a description of the function:def polygonize(self, width, cap_style_line=CAP_STYLE.flat, cap_style_point=CAP_STYLE.round):
shape = self._shape
if isinstance(shape, (LineString, MultiLineString)):
return self.__class__(
shape.buffer(width / 2, cap_style... | [
"Turns line or point into a buffered polygon."
] |
Please provide a description of the function:def tiles(self, zooms, truncate=False):
west, south, east, north = self.get_bounds(WGS84_CRS)
return tiles(west, south, east, north, zooms, truncate) | [
"\n Iterator over the tiles intersecting the bounding box of the vector\n\n Parameters\n ----------\n zooms : int or sequence of int\n One or more zoom levels.\n truncate : bool, optional\n Whether or not to truncate inputs to web mercator limits.\n\n... |
Please provide a description of the function:def _join_masks_from_masked_array(data):
if not isinstance(data.mask, np.ndarray):
# workaround to handle mask compressed to single value
mask = np.empty(data.data.shape, dtype=np.bool)
mask.fill(data.mask)
return mask
mask = data... | [
"Union of masks."
] |
Please provide a description of the function:def _creation_options_for_cog(creation_options, source_profile, blocksize):
if not(creation_options):
creation_options = {}
creation_options["blocksize"] = blocksize
creation_options["tiled"] = True
defaults = {"nodata": None, "compress": "lzw"}... | [
"\n it uses the profile of the source raster, override anything using the creation_options\n and guarantees we will have tiled raster and blocksize\n "
] |
Please provide a description of the function:def convert_to_cog(source_file, destination_file, resampling=rasterio.enums.Resampling.gauss, blocksize=256,
overview_blocksize=256, creation_options=None):
with rasterio.open(source_file) as src:
# creation_options overrides proile
... | [
"Convert source file to a Cloud Optimized GeoTiff new file.\n\n :param source_file: path to the original raster\n :param destination_file: path to the new raster\n :param resampling: which Resampling to use on reading, default Resampling.gauss\n :param blocksize: the size of the blocks default 256\n ... |
Please provide a description of the function:def calc_transform(src, dst_crs=None, resolution=None, dimensions=None,
src_bounds=None, dst_bounds=None, target_aligned_pixels=False):
if resolution is not None:
if isinstance(resolution, (float, int)):
resolution = (float(res... | [
"Output dimensions and transform for a reprojection.\n\n Parameters\n ------------\n src: rasterio.io.DatasetReader\n Data source.\n dst_crs: rasterio.crs.CRS, optional\n Target coordinate reference system.\n resolution: tuple (x resolution, y resolution) or float, optional\n Tar... |
Please provide a description of the function:def warp(source_file, destination_file, dst_crs=None, resolution=None, dimensions=None,
src_bounds=None, dst_bounds=None, src_nodata=None, dst_nodata=None,
target_aligned_pixels=False, check_invert_proj=True,
creation_options=None, resampling=Resam... | [
"Warp a raster dataset.\n\n Parameters\n ------------\n source_file: str, file object or pathlib.Path object\n Source file.\n destination_file: str, file object or pathlib.Path object\n Destination file.\n dst_crs: rasterio.crs.CRS, optional\n Target coordinate reference system.\... |
Please provide a description of the function:def build_overviews(source_file, factors=None, minsize=256, external=False,
blocksize=256, interleave='pixel', compress='lzw',
resampling=Resampling.gauss, **kwargs):
with rasterio.open(source_file, 'r+') as dst:
if f... | [
"Build overviews at one or more decimation factors for all\n bands of the dataset.\n\n Parameters\n ------------\n source_file : str, file object or pathlib.Path object\n Source file.\n factors : list, optional\n A list of integral overview levels to build.\n minsize : int, optional\... |
Please provide a description of the function:def build_vrt(source_file, destination_file, **kwargs):
with rasterio.open(source_file) as src:
vrt_doc = boundless_vrt_doc(src, **kwargs).tostring()
with open(destination_file, 'wb') as dst:
dst.write(vrt_doc)
return destination_fi... | [
"Make a VRT XML document and write it in file.\n\n Parameters\n ----------\n source_file : str, file object or pathlib.Path object\n Source file.\n destination_file : str\n Destination file.\n kwargs : optional\n Additional arguments passed to rasterio.vrt._boundless_vrt_doc\n\n ... |
Please provide a description of the function:def stretch_histogram(img, dark_clip_percentile=None, bright_clip_percentile=None,
dark_clip_value=None, bright_clip_value=None, ignore_zero=True):
# verify stretching method is specified:
if (dark_clip_percentile is not None and dark_clip_... | [
"Stretch img histogram.\n\n 2 possible modes: by percentile (pass dark/bright_clip_percentile), or by value (pass dark/bright_clip_value)\n :param dark_clip_percentile: percent of pixels that will be saturated to min_value\n :param bright_clip_percentile: percent of pixels that will be saturated to max_val... |
Please provide a description of the function:def _distribution_info(self):
print('Gathering information...')
system = platform.system()
# Cygwin system is CYGWIN-NT-xxx.
system = 'cygwin' if 'CYGWIN' in system else system
processor = platform.processor()
machi... | [
"Creates the distribution name and the expected extension for the\n CSPICE package and returns it.\n\n :return (distribution, extension) tuple where distribution is the best\n guess from the strings available within the platform_urls list\n of strings, and extension is ei... |
Please provide a description of the function:def _download(self):
# Use urllib3 (based on PyOpenSSL).
if ssl.OPENSSL_VERSION < 'OpenSSL 1.0.1g':
# Force urllib3 to use pyOpenSSL
import urllib3.contrib.pyopenssl
urllib3.contrib.pyopenssl.inject_into_urllib3()
... | [
"Support function that encapsulates the OpenSSL transfer of the CSPICE\n package to the self._local io.ByteIO stream.\n\n :raises RuntimeError if there has been any issue with the HTTPS\n communication\n\n .. note::\n\n Handling of CSPICE downloads from HTT... |
Please provide a description of the function:def _unpack(self):
if self._ext == 'zip':
with ZipFile(self._local, 'r') as archive:
archive.extractall(self._root)
else:
cmd = 'gunzip | tar xC ' + self._root
proc = subprocess.Popen(cmd, shell=Tru... | [
"Unpacks the CSPICE package on the given root directory. Note that\n Package could either be the zipfile.ZipFile class for Windows platforms\n or tarfile.TarFile for other platforms.\n "
] |
Please provide a description of the function:def checkForSpiceError(f):
if failed():
errorparts = {
"tkvsn": tkvrsn("TOOLKIT").replace("CSPICE_", ""),
"short": getmsg("SHORT", 26),
"explain": getmsg("EXPLAIN", 100).strip(),
"long": getmsg("LONG", 321).str... | [
"\n Internal function to check\n :param f:\n :raise stypes.SpiceyError:\n "
] |
Please provide a description of the function:def spiceErrorCheck(f):
@functools.wraps(f)
def with_errcheck(*args, **kwargs):
try:
res = f(*args, **kwargs)
checkForSpiceError(f)
return res
except:
raise
return with_errcheck | [
"\n Decorator for spiceypy hooking into spice error system.\n If an error is detected, an output similar to outmsg\n\n :type f: builtins.function\n :return:\n :rtype:\n "
] |
Please provide a description of the function:def spiceFoundExceptionThrower(f):
@functools.wraps(f)
def wrapper(*args, **kwargs):
res = f(*args, **kwargs)
if config.catch_false_founds:
found = res[-1]
if isinstance(found, bool) and not found:
raise st... | [
"\n Decorator for wrapping functions that use status codes\n "
] |
Please provide a description of the function:def no_found_check():
current_catch_state = config.catch_false_founds
config.catch_false_founds = False
yield
config.catch_false_founds = current_catch_state | [
"\n Temporarily disables spiceypy default behavior which raises exceptions for\n false found flags for certain spice functions. All spice\n functions executed within the context manager will no longer check the found\n flag return parameter and the found flag will be included in the return for\n the ... |
Please provide a description of the function:def found_check():
current_catch_state = config.catch_false_founds
config.catch_false_founds = True
yield
config.catch_false_founds = current_catch_state | [
"\n Temporarily enables spiceypy default behavior which raises exceptions for\n false found flags for certain spice functions. All spice\n functions executed within the context manager will check the found\n flag return parameter and the found flag will be removed from the return for\n the given func... |
Please provide a description of the function:def appndc(item, cell):
assert isinstance(cell, stypes.SpiceCell)
if isinstance(item, list):
for c in item:
libspice.appndc_c(stypes.stringToCharP(c), cell)
else:
item = stypes.stringToCharP(item)
libspice.appndc_c(item, c... | [
"\n Append an item to a character cell.\n\n http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/appndc_c.html\n\n :param item: The item to append.\n :type item: str or list\n :param cell: The cell to append to.\n :type cell: spiceypy.utils.support_types.SpiceCell\n "
] |
Please provide a description of the function:def appndd(item, cell):
assert isinstance(cell, stypes.SpiceCell)
if hasattr(item, "__iter__"):
for d in item:
libspice.appndd_c(ctypes.c_double(d), cell)
else:
item = ctypes.c_double(item)
libspice.appndd_c(item, cell) | [
"\n Append an item to a double precision cell.\n\n http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/appndd_c.html\n\n :param item: The item to append.\n :type item: Union[float,Iterable[float]]\n :param cell: The cell to append to.\n :type cell: spiceypy.utils.support_types.SpiceCell\n "... |
Please provide a description of the function:def appndi(item, cell):
assert isinstance(cell, stypes.SpiceCell)
if hasattr(item, "__iter__"):
for i in item:
libspice.appndi_c(ctypes.c_int(i), cell)
else:
item = ctypes.c_int(item)
libspice.appndi_c(item, cell) | [
"\n Append an item to an integer cell.\n\n http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/appndi_c.html\n\n :param item: The item to append.\n :type item: Union[float,Iterable[int]]\n :param cell: The cell to append to.\n :type cell: spiceypy.utils.support_types.SpiceCell\n "
] |
Please provide a description of the function:def axisar(axis, angle):
axis = stypes.toDoubleVector(axis)
angle = ctypes.c_double(angle)
r = stypes.emptyDoubleMatrix()
libspice.axisar_c(axis, angle, r)
return stypes.cMatrixToNumpy(r) | [
"\n Construct a rotation matrix that rotates vectors by a specified\n angle about a specified axis.\n\n http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/axisar_c.html\n\n :param axis: Rotation axis. \n :type axis: 3 Element vector (list, tuple, numpy array)\n :param angle: Rotation angle, i... |
Please provide a description of the function:def badkpv(caller, name, comp, insize, divby, intype):
caller = stypes.stringToCharP(caller)
name = stypes.stringToCharP(name)
comp = stypes.stringToCharP(comp)
insize = ctypes.c_int(insize)
divby = ctypes.c_int(divby)
intype = ctypes.c_char(inty... | [
"\n Determine if a kernel pool variable is present and if so\n that it has the correct size and type.\n\n http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/badkpv_c.html\n\n :param caller: Name of the routine calling this routine.\n :type caller: str\n :param name: Name of a kernel pool vari... |
Please provide a description of the function:def bltfrm(frmcls, outCell=None):
frmcls = ctypes.c_int(frmcls)
if not outCell:
outCell = stypes.SPICEINT_CELL(1000)
libspice.bltfrm_c(frmcls, outCell)
return outCell | [
"\n Return a SPICE set containing the frame IDs of all built-in frames\n of a specified class.\n\n http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/bltfrm_c.html\n\n :param frmcls: Frame class.\n :type frmcls: int\n :param outCell: Optional SpiceInt Cell that is returned\n :type outCell:... |
Please provide a description of the function:def bodc2n(code, lenout=_default_len_out):
code = ctypes.c_int(code)
name = stypes.stringToCharP(" " * lenout)
lenout = ctypes.c_int(lenout)
found = ctypes.c_int()
libspice.bodc2n_c(code, lenout, name, ctypes.byref(found))
return stypes.toPythonS... | [
"\n Translate the SPICE integer code of a body into a common name\n for that body.\n\n http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/bodc2n_c.html\n\n :param code: Integer ID code to be translated into a name.\n :type code: int\n :param lenout: Maximum length of output name.\n :type l... |
Please provide a description of the function:def bodc2s(code, lenout=_default_len_out):
code = ctypes.c_int(code)
name = stypes.stringToCharP(" " * lenout)
lenout = ctypes.c_int(lenout)
libspice.bodc2s_c(code, lenout, name)
return stypes.toPythonString(name) | [
"\n Translate a body ID code to either the corresponding name or if no\n name to ID code mapping exists, the string representation of the\n body ID value.\n\n http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/bodc2s_c.html\n\n :param code: Integer ID code to translate to a string.\n :type co... |
Please provide a description of the function:def boddef(name, code):
name = stypes.stringToCharP(name)
code = ctypes.c_int(code)
libspice.boddef_c(name, code) | [
"\n Define a body name/ID code pair for later translation via\n :func:`bodn2c` or :func:`bodc2n`.\n\n http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/boddef_c.html\n\n :param name: Common name of some body.\n :type name: str\n :param code: Integer code for that body.\n :type code: int\n... |
Please provide a description of the function:def bodfnd(body, item):
body = ctypes.c_int(body)
item = stypes.stringToCharP(item)
return bool(libspice.bodfnd_c(body, item)) | [
"\n Determine whether values exist for some item for any body\n in the kernel pool.\n\n http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/bodfnd_c.html\n\n :param body: ID code of body.\n :type body: int\n :param item: Item to find (\"RADII\", \"NUT_AMP_RA\", etc.).\n :type item: str\n ... |
Please provide a description of the function:def bodn2c(name):
name = stypes.stringToCharP(name)
code = ctypes.c_int(0)
found = ctypes.c_int(0)
libspice.bodn2c_c(name, ctypes.byref(code), ctypes.byref(found))
return code.value, bool(found.value) | [
"\n Translate the name of a body or object to the corresponding SPICE\n integer ID code.\n\n http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/bodn2c_c.html\n\n :param name: Body name to be translated into a SPICE ID code.\n :type name: str\n :return: SPICE integer ID code for the named body... |
Please provide a description of the function:def bods2c(name):
name = stypes.stringToCharP(name)
code = ctypes.c_int(0)
found = ctypes.c_int(0)
libspice.bods2c_c(name, ctypes.byref(code), ctypes.byref(found))
return code.value, bool(found.value) | [
"\n Translate a string containing a body name or ID code to an integer code.\n\n http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/bods2c_c.html\n\n :param name: String to be translated to an ID code.\n :type name: str\n :return: Integer ID code corresponding to name.\n :rtype: int\n "
] |
Please provide a description of the function:def bodvar(body, item, dim):
body = ctypes.c_int(body)
dim = ctypes.c_int(dim)
item = stypes.stringToCharP(item)
values = stypes.emptyDoubleVector(dim.value)
libspice.bodvar_c(body, item, ctypes.byref(dim), values)
return stypes.cVectorToPython(v... | [
"\n Deprecated: This routine has been superseded by :func:`bodvcd` and\n :func:`bodvrd`. This routine is supported for purposes of backward\n compatibility only.\n\n Return the values of some item for any body in the kernel pool.\n\n http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/bodvar_c.ht... |
Please provide a description of the function:def bodvcd(bodyid, item, maxn):
bodyid = ctypes.c_int(bodyid)
item = stypes.stringToCharP(item)
dim = ctypes.c_int()
values = stypes.emptyDoubleVector(maxn)
maxn = ctypes.c_int(maxn)
libspice.bodvcd_c(bodyid, item, maxn, ctypes.byref(dim), values... | [
"\n Fetch from the kernel pool the double precision values of an item\n associated with a body, where the body is specified by an integer ID\n code.\n\n http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/bodvcd_c.html\n\n :param bodyid: Body ID code.\n :type bodyid: int\n :param item:\n ... |
Please provide a description of the function:def bodvrd(bodynm, item, maxn):
bodynm = stypes.stringToCharP(bodynm)
item = stypes.stringToCharP(item)
dim = ctypes.c_int()
values = stypes.emptyDoubleVector(maxn)
maxn = ctypes.c_int(maxn)
libspice.bodvrd_c(bodynm, item, maxn, ctypes.byref(dim)... | [
"\n Fetch from the kernel pool the double precision values\n of an item associated with a body.\n\n http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/bodvrd_c.html\n\n :param bodynm: Body name.\n :type bodynm: str\n :param item:\n Item for which values are desired,\n ... |
Please provide a description of the function:def brcktd(number, end1, end2):
number = ctypes.c_double(number)
end1 = ctypes.c_double(end1)
end2 = ctypes.c_double(end2)
return libspice.brcktd_c(number, end1, end2) | [
"\n Bracket a number. That is, given a number and an acceptable\n interval, make sure that the number is contained in the\n interval. (If the number is already in the interval, leave it\n alone. If not, set it to the nearest endpoint of the interval.)\n\n http://naif.jpl.nasa.gov/pub/naif/toolkit_doc... |
Please provide a description of the function:def brckti(number, end1, end2):
number = ctypes.c_int(number)
end1 = ctypes.c_int(end1)
end2 = ctypes.c_int(end2)
return libspice.brckti_c(number, end1, end2) | [
"\n Bracket a number. That is, given a number and an acceptable\n interval, make sure that the number is contained in the\n interval. (If the number is already in the interval, leave it\n alone. If not, set it to the nearest endpoint of the interval.)\n\n http://naif.jpl.nasa.gov/pub/naif/toolkit_doc... |
Please provide a description of the function:def bschoc(value, ndim, lenvals, array, order):
value = stypes.stringToCharP(value)
ndim = ctypes.c_int(ndim)
lenvals = ctypes.c_int(lenvals)
array = stypes.listToCharArrayPtr(array, xLen=lenvals, yLen=ndim)
order = stypes.toIntVector(order)
retu... | [
"\n Do a binary search for a given value within a character string array,\n accompanied by an order vector. Return the index of the matching array\n entry, or -1 if the key value is not found.\n\n http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/bschoc_c.html\n\n :param value: Key value to be... |
Please provide a description of the function:def bschoi(value, ndim, array, order):
value = ctypes.c_int(value)
ndim = ctypes.c_int(ndim)
array = stypes.toIntVector(array)
order = stypes.toIntVector(order)
return libspice.bschoi_c(value, ndim, array, order) | [
"\n Do a binary search for a given value within an integer array,\n accompanied by an order vector. Return the index of the\n matching array entry, or -1 if the key value is not found.\n\n http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/bschoi_c.html\n\n :param value: Key value to be found i... |
Please provide a description of the function:def bsrchc(value, ndim, lenvals, array):
value = stypes.stringToCharP(value)
ndim = ctypes.c_int(ndim)
lenvals = ctypes.c_int(lenvals)
array = stypes.listToCharArrayPtr(array, xLen=lenvals, yLen=ndim)
return libspice.bsrchc_c(value, ndim, lenvals, ar... | [
"\n Do a binary earch for a given value within a character string array.\n Return the index of the first matching array entry, or -1 if the key\n value was not found.\n\n http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/bsrchc_c.html\n\n :param value: Key value to be found in array.\n :type... |
Please provide a description of the function:def bsrchd(value, ndim, array):
value = ctypes.c_double(value)
ndim = ctypes.c_int(ndim)
array = stypes.toDoubleVector(array)
return libspice.bsrchd_c(value, ndim, array) | [
"\n Do a binary search for a key value within a double precision array,\n assumed to be in increasing order. Return the index of the matching\n array entry, or -1 if the key value is not found.\n\n http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/bsrchd_c.html\n\n :param value: Value to find i... |
Please provide a description of the function:def bsrchi(value, ndim, array):
value = ctypes.c_int(value)
ndim = ctypes.c_int(ndim)
array = stypes.toIntVector(array)
return libspice.bsrchi_c(value, ndim, array) | [
"\n Do a binary search for a key value within an integer array,\n assumed to be in increasing order. Return the index of the\n matching array entry, or -1 if the key value is not found.\n\n http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/bsrchi_c.html\n\n :param value: Value to find in array.... |
Please provide a description of the function:def ccifrm(frclss, clssid, lenout=_default_len_out):
frclss = ctypes.c_int(frclss)
clssid = ctypes.c_int(clssid)
lenout = ctypes.c_int(lenout)
frcode = ctypes.c_int()
frname = stypes.stringToCharP(lenout)
center = ctypes.c_int()
found = ctype... | [
"\n Return the frame name, frame ID, and center associated with\n a given frame class and class ID.\n\n http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/ccifrm_c.html\n\n :param frclss: Class of frame.\n :type frclss: int\n :param clssid: Class ID of frame.\n :type clssid: int\n :para... |
Please provide a description of the function:def cgv2el(center, vec1, vec2):
center = stypes.toDoubleVector(center)
vec1 = stypes.toDoubleVector(vec1)
vec2 = stypes.toDoubleVector(vec2)
ellipse = stypes.Ellipse()
libspice.cgv2el_c(center, vec1, vec2, ctypes.byref(ellipse))
return ellipse | [
"\n Form a SPICE ellipse from a center vector and two generating vectors.\n\n http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/cgv2el_c.html\n\n :param center: Center Vector\n :type center: 3-Element Array of floats\n :param vec1: Vector 1\n :type vec1: 3-Element Array of floats\n :param... |
Please provide a description of the function:def chbder(cp, degp, x2s, x, nderiv):
cp = stypes.toDoubleVector(cp)
degp = ctypes.c_int(degp)
x2s = stypes.toDoubleVector(x2s)
x = ctypes.c_double(x)
partdp = stypes.emptyDoubleVector(3*(nderiv+1))
dpdxs = stypes.emptyDoubleVector(nderiv+1)
... | [
"\n Given the coefficients for the Chebyshev expansion of a\n polynomial, this returns the value of the polynomial and its\n first nderiv derivatives evaluated at the input X.\n \n https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/chbder_c.html\n \n :param cp: degp+1 Chebyshev polynomial... |
Please provide a description of the function:def cidfrm(cent, lenout=_default_len_out):
cent = ctypes.c_int(cent)
lenout = ctypes.c_int(lenout)
frcode = ctypes.c_int()
frname = stypes.stringToCharP(lenout)
found = ctypes.c_int()
libspice.cidfrm_c(cent, lenout, ctypes.byref(frcode), frname,
... | [
"\n Retrieve frame ID code and name to associate with a frame center.\n\n http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/cidfrm_c.html\n\n :param cent: An object to associate a frame with.\n :type cent: int\n :param lenout: Available space in output string frname.\n :type lenout: int\n ... |
Please provide a description of the function:def ckcov(ck, idcode, needav, level, tol, timsys, cover=None):
ck = stypes.stringToCharP(ck)
idcode = ctypes.c_int(idcode)
needav = ctypes.c_int(needav)
level = stypes.stringToCharP(level)
tol = ctypes.c_double(tol)
timsys = stypes.stringToCharP(... | [
"\n Find the coverage window for a specified object in a specified CK file.\n\n http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/ckcov_c.html\n\n :param ck: Name of CK file.\n :type ck: str\n :param idcode: ID code of object.\n :type idcode: int\n :param needav: Flag indicating whether a... |
Please provide a description of the function:def ckgp(inst, sclkdp, tol, ref):
inst = ctypes.c_int(inst)
sclkdp = ctypes.c_double(sclkdp)
tol = ctypes.c_double(tol)
ref = stypes.stringToCharP(ref)
cmat = stypes.emptyDoubleMatrix()
clkout = ctypes.c_double()
found = ctypes.c_int()
li... | [
"\n Get pointing (attitude) for a specified spacecraft clock time.\n\n http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/ckgp_c.html\n\n :param inst: NAIF ID of instrument, spacecraft, or structure.\n :type inst: int\n :param sclkdp: Encoded spacecraft clock time.\n :type sclkdp: float\n ... |
Please provide a description of the function:def ckgpav(inst, sclkdp, tol, ref):
inst = ctypes.c_int(inst)
sclkdp = ctypes.c_double(sclkdp)
tol = ctypes.c_double(tol)
ref = stypes.stringToCharP(ref)
cmat = stypes.emptyDoubleMatrix()
av = stypes.emptyDoubleVector(3)
clkout = ctypes.c_dou... | [
"\n Get pointing (attitude) and angular velocity\n for a specified spacecraft clock time.\n\n http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/ckgpav_c.html\n\n :param inst: NAIF ID of instrument, spacecraft, or structure.\n :type inst: int\n :param sclkdp: Encoded spacecraft clock time.\n ... |
Please provide a description of the function:def cklpf(filename):
filename = stypes.stringToCharP(filename)
handle = ctypes.c_int()
libspice.cklpf_c(filename, ctypes.byref(handle))
return handle.value | [
"\n Load a CK pointing file for use by the CK readers. Return that\n file's handle, to be used by other CK routines to refer to the\n file.\n\n http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/cklpf_c.html\n\n :param filename: Name of the CK file to be loaded.\n :type filename: str\n :r... |
Please provide a description of the function:def ckobj(ck, outCell=None):
assert isinstance(ck, str)
ck = stypes.stringToCharP(ck)
if not outCell:
outCell = stypes.SPICEINT_CELL(1000)
assert isinstance(outCell, stypes.SpiceCell)
assert outCell.dtype == 2
libspice.ckobj_c(ck, ctypes.... | [
"\n Find the set of ID codes of all objects in a specified CK file.\n\n http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/ckobj_c.html\n\n :param ck: Name of CK file.\n :type ck: str\n :param outCell: Optional user provided Spice Int cell.\n :type outCell: Optional spiceypy.utils.support_typ... |
Please provide a description of the function:def ckopn(filename, ifname, ncomch):
filename = stypes.stringToCharP(filename)
ifname = stypes.stringToCharP(ifname)
ncomch = ctypes.c_int(ncomch)
handle = ctypes.c_int()
libspice.ckopn_c(filename, ifname, ncomch, ctypes.byref(handle))
return han... | [
"\n Open a new CK file, returning the handle of the opened file.\n\n http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/ckopn_c.html\n\n :param filename: The name of the CK file to be opened.\n :type filename: str\n :param ifname: The internal filename for the CK.\n :type ifname: str\n :pa... |
Please provide a description of the function:def ckw01(handle, begtim, endtim, inst, ref, avflag, segid, nrec, sclkdp, quats,
avvs):
handle = ctypes.c_int(handle)
begtim = ctypes.c_double(begtim)
endtim = ctypes.c_double(endtim)
inst = ctypes.c_int(inst)
ref = stypes.stringToCharP(ref... | [
"\n Add a type 1 segment to a C-kernel.\n\n http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/ckw01_c.html\n\n :param handle: Handle of an open CK file.\n :type handle: int\n :param begtim: The beginning encoded SCLK of the segment.\n :type begtim: float\n :param endtim: The ending encode... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.