repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
1 value
koordinates/python-client
koordinates/layers.py
Layer.is_published_version
def is_published_version(self): """ Return if this version is the published version of a layer """ pub_ver = getattr(self, 'published_version', None) this_ver = getattr(self, 'this_version', None) return this_ver and pub_ver and (this_ver == pub_ver)
python
def is_published_version(self): """ Return if this version is the published version of a layer """ pub_ver = getattr(self, 'published_version', None) this_ver = getattr(self, 'this_version', None) return this_ver and pub_ver and (this_ver == pub_ver)
[ "def", "is_published_version", "(", "self", ")", ":", "pub_ver", "=", "getattr", "(", "self", ",", "'published_version'", ",", "None", ")", "this_ver", "=", "getattr", "(", "self", ",", "'this_version'", ",", "None", ")", "return", "this_ver", "and", "pub_ve...
Return if this version is the published version of a layer
[ "Return", "if", "this", "version", "is", "the", "published", "version", "of", "a", "layer" ]
f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252
https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/layers.py#L172-L176
train
koordinates/python-client
koordinates/layers.py
Layer.is_draft_version
def is_draft_version(self): """ Return if this version is the draft version of a layer """ pub_ver = getattr(self, 'published_version', None) latest_ver = getattr(self, 'latest_version', None) this_ver = getattr(self, 'this_version', None) return this_ver and latest_ver and (this...
python
def is_draft_version(self): """ Return if this version is the draft version of a layer """ pub_ver = getattr(self, 'published_version', None) latest_ver = getattr(self, 'latest_version', None) this_ver = getattr(self, 'this_version', None) return this_ver and latest_ver and (this...
[ "def", "is_draft_version", "(", "self", ")", ":", "pub_ver", "=", "getattr", "(", "self", ",", "'published_version'", ",", "None", ")", "latest_ver", "=", "getattr", "(", "self", ",", "'latest_version'", ",", "None", ")", "this_ver", "=", "getattr", "(", "...
Return if this version is the draft version of a layer
[ "Return", "if", "this", "version", "is", "the", "draft", "version", "of", "a", "layer" ]
f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252
https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/layers.py#L179-L184
train
koordinates/python-client
koordinates/layers.py
Layer.list_versions
def list_versions(self): """ Filterable list of versions of a layer, always ordered newest to oldest. If the version’s source supports revisions, you can get a specific revision using ``.filter(data__source__revision=value)``. Specific values depend on the source type. Use ``dat...
python
def list_versions(self): """ Filterable list of versions of a layer, always ordered newest to oldest. If the version’s source supports revisions, you can get a specific revision using ``.filter(data__source__revision=value)``. Specific values depend on the source type. Use ``dat...
[ "def", "list_versions", "(", "self", ")", ":", "target_url", "=", "self", ".", "_client", ".", "get_url", "(", "'VERSION'", ",", "'GET'", ",", "'multi'", ",", "{", "'layer_id'", ":", "self", ".", "id", "}", ")", "return", "base", ".", "Query", "(", "...
Filterable list of versions of a layer, always ordered newest to oldest. If the version’s source supports revisions, you can get a specific revision using ``.filter(data__source__revision=value)``. Specific values depend on the source type. Use ``data__source_revision__lt`` or ``data__source_re...
[ "Filterable", "list", "of", "versions", "of", "a", "layer", "always", "ordered", "newest", "to", "oldest", "." ]
f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252
https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/layers.py#L187-L197
train
koordinates/python-client
koordinates/layers.py
Layer.get_version
def get_version(self, version_id, expand=[]): """ Get a specific version of this layer """ target_url = self._client.get_url('VERSION', 'GET', 'single', {'layer_id': self.id, 'version_id': version_id}) return self._manager._get(target_url, expand=expand)
python
def get_version(self, version_id, expand=[]): """ Get a specific version of this layer """ target_url = self._client.get_url('VERSION', 'GET', 'single', {'layer_id': self.id, 'version_id': version_id}) return self._manager._get(target_url, expand=expand)
[ "def", "get_version", "(", "self", ",", "version_id", ",", "expand", "=", "[", "]", ")", ":", "target_url", "=", "self", ".", "_client", ".", "get_url", "(", "'VERSION'", ",", "'GET'", ",", "'single'", ",", "{", "'layer_id'", ":", "self", ".", "id", ...
Get a specific version of this layer
[ "Get", "a", "specific", "version", "of", "this", "layer" ]
f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252
https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/layers.py#L200-L205
train
koordinates/python-client
koordinates/layers.py
Layer.get_draft_version
def get_draft_version(self, expand=[]): """ Get the current draft version of this layer. :raises NotFound: if there is no draft version. """ target_url = self._client.get_url('VERSION', 'GET', 'draft', {'layer_id': self.id}) return self._manager._get(target_url, expand=ex...
python
def get_draft_version(self, expand=[]): """ Get the current draft version of this layer. :raises NotFound: if there is no draft version. """ target_url = self._client.get_url('VERSION', 'GET', 'draft', {'layer_id': self.id}) return self._manager._get(target_url, expand=ex...
[ "def", "get_draft_version", "(", "self", ",", "expand", "=", "[", "]", ")", ":", "target_url", "=", "self", ".", "_client", ".", "get_url", "(", "'VERSION'", ",", "'GET'", ",", "'draft'", ",", "{", "'layer_id'", ":", "self", ".", "id", "}", ")", "ret...
Get the current draft version of this layer. :raises NotFound: if there is no draft version.
[ "Get", "the", "current", "draft", "version", "of", "this", "layer", ".", ":", "raises", "NotFound", ":", "if", "there", "is", "no", "draft", "version", "." ]
f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252
https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/layers.py#L208-L214
train
koordinates/python-client
koordinates/layers.py
Layer.start_import
def start_import(self, version_id=None): """ Starts importing this draft layerversion (cancelling any running import), even if the data object hasn’t changed from the previous version. :raises Conflict: if this version is already published. """ if not version_id: ...
python
def start_import(self, version_id=None): """ Starts importing this draft layerversion (cancelling any running import), even if the data object hasn’t changed from the previous version. :raises Conflict: if this version is already published. """ if not version_id: ...
[ "def", "start_import", "(", "self", ",", "version_id", "=", "None", ")", ":", "if", "not", "version_id", ":", "version_id", "=", "self", ".", "version", ".", "id", "target_url", "=", "self", ".", "_client", ".", "get_url", "(", "'VERSION'", ",", "'POST'"...
Starts importing this draft layerversion (cancelling any running import), even if the data object hasn’t changed from the previous version. :raises Conflict: if this version is already published.
[ "Starts", "importing", "this", "draft", "layerversion", "(", "cancelling", "any", "running", "import", ")", "even", "if", "the", "data", "object", "hasn’t", "changed", "from", "the", "previous", "version", "." ]
f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252
https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/layers.py#L242-L254
train
koordinates/python-client
koordinates/layers.py
Layer.start_update
def start_update(self): """ A shortcut to create a new version and start importing it. Effectively the same as :py:meth:`.create_draft_version` followed by :py:meth:`koordinates.layers.Layer.start_import`. :rtype: Layer :return: the new version :raises Conflict: if there...
python
def start_update(self): """ A shortcut to create a new version and start importing it. Effectively the same as :py:meth:`.create_draft_version` followed by :py:meth:`koordinates.layers.Layer.start_import`. :rtype: Layer :return: the new version :raises Conflict: if there...
[ "def", "start_update", "(", "self", ")", ":", "target_url", "=", "self", ".", "_client", ".", "get_url", "(", "'LAYER'", ",", "'POST'", ",", "'update'", ",", "{", "'layer_id'", ":", "self", ".", "id", "}", ")", "r", "=", "self", ".", "_client", ".", ...
A shortcut to create a new version and start importing it. Effectively the same as :py:meth:`.create_draft_version` followed by :py:meth:`koordinates.layers.Layer.start_import`. :rtype: Layer :return: the new version :raises Conflict: if there is already a draft version for this layer.
[ "A", "shortcut", "to", "create", "a", "new", "version", "and", "start", "importing", "it", ".", "Effectively", "the", "same", "as", ":", "py", ":", "meth", ":", ".", "create_draft_version", "followed", "by", ":", "py", ":", "meth", ":", "koordinates", "....
f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252
https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/layers.py#L257-L268
train
koordinates/python-client
koordinates/layers.py
Layer.publish
def publish(self, version_id=None): """ Creates a publish task just for this version, which publishes as soon as any import is complete. :return: the publish task :rtype: Publish :raises Conflict: If the version is already published, or already has a publish job. """ ...
python
def publish(self, version_id=None): """ Creates a publish task just for this version, which publishes as soon as any import is complete. :return: the publish task :rtype: Publish :raises Conflict: If the version is already published, or already has a publish job. """ ...
[ "def", "publish", "(", "self", ",", "version_id", "=", "None", ")", ":", "if", "not", "version_id", ":", "version_id", "=", "self", ".", "version", ".", "id", "target_url", "=", "self", ".", "_client", ".", "get_url", "(", "'VERSION'", ",", "'POST'", "...
Creates a publish task just for this version, which publishes as soon as any import is complete. :return: the publish task :rtype: Publish :raises Conflict: If the version is already published, or already has a publish job.
[ "Creates", "a", "publish", "task", "just", "for", "this", "version", "which", "publishes", "as", "soon", "as", "any", "import", "is", "complete", "." ]
f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252
https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/layers.py#L271-L284
train
koordinates/python-client
koordinates/layers.py
Layer.save
def save(self, with_data=False): """ Edits this draft layerversion. # If anything in the data object has changed, cancel any existing import and start a new one. :param bool with_data: if ``True``, send the data object, which will start a new import and cancel any existing o...
python
def save(self, with_data=False): """ Edits this draft layerversion. # If anything in the data object has changed, cancel any existing import and start a new one. :param bool with_data: if ``True``, send the data object, which will start a new import and cancel any existing o...
[ "def", "save", "(", "self", ",", "with_data", "=", "False", ")", ":", "target_url", "=", "self", ".", "_client", ".", "get_url", "(", "'VERSION'", ",", "'PUT'", ",", "'edit'", ",", "{", "'layer_id'", ":", "self", ".", "id", ",", "'version_id'", ":", ...
Edits this draft layerversion. # If anything in the data object has changed, cancel any existing import and start a new one. :param bool with_data: if ``True``, send the data object, which will start a new import and cancel any existing one. If ``False``, the data object will *not* be sent,...
[ "Edits", "this", "draft", "layerversion", ".", "#", "If", "anything", "in", "the", "data", "object", "has", "changed", "cancel", "any", "existing", "import", "and", "start", "a", "new", "one", "." ]
f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252
https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/layers.py#L287-L298
train
koordinates/python-client
koordinates/layers.py
Layer.delete_version
def delete_version(self, version_id=None): """ Deletes this draft version (revert to published) :raises NotAllowed: if this version is already published. :raises Conflict: if this version is already deleted. """ if not version_id: version_id = self.version.id...
python
def delete_version(self, version_id=None): """ Deletes this draft version (revert to published) :raises NotAllowed: if this version is already published. :raises Conflict: if this version is already deleted. """ if not version_id: version_id = self.version.id...
[ "def", "delete_version", "(", "self", ",", "version_id", "=", "None", ")", ":", "if", "not", "version_id", ":", "version_id", "=", "self", ".", "version", ".", "id", "target_url", "=", "self", ".", "_client", ".", "get_url", "(", "'VERSION'", ",", "'DELE...
Deletes this draft version (revert to published) :raises NotAllowed: if this version is already published. :raises Conflict: if this version is already deleted.
[ "Deletes", "this", "draft", "version", "(", "revert", "to", "published", ")" ]
f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252
https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/layers.py#L301-L313
train
koordinates/python-client
koordinates/catalog.py
CatalogManager._get_item_class
def _get_item_class(self, url): """ Return the model class matching a URL """ if '/layers/' in url: return Layer elif '/tables/' in url: return Table elif '/sets/' in url: return Set # elif '/documents/' in url: # return Document ...
python
def _get_item_class(self, url): """ Return the model class matching a URL """ if '/layers/' in url: return Layer elif '/tables/' in url: return Table elif '/sets/' in url: return Set # elif '/documents/' in url: # return Document ...
[ "def", "_get_item_class", "(", "self", ",", "url", ")", ":", "if", "'/layers/'", "in", "url", ":", "return", "Layer", "elif", "'/tables/'", "in", "url", ":", "return", "Table", "elif", "'/sets/'", "in", "url", ":", "return", "Set", "# elif '/documents/' in u...
Return the model class matching a URL
[ "Return", "the", "model", "class", "matching", "a", "URL" ]
f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252
https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/catalog.py#L40-L51
train
michaelaye/pyciss
pyciss/solitons.py
get_year_since_resonance
def get_year_since_resonance(ringcube): "Calculate the fraction of the year since moon swap." t0 = dt(2006, 1, 21) td = ringcube.imagetime - t0 return td.days / 365.25
python
def get_year_since_resonance(ringcube): "Calculate the fraction of the year since moon swap." t0 = dt(2006, 1, 21) td = ringcube.imagetime - t0 return td.days / 365.25
[ "def", "get_year_since_resonance", "(", "ringcube", ")", ":", "t0", "=", "dt", "(", "2006", ",", "1", ",", "21", ")", "td", "=", "ringcube", ".", "imagetime", "-", "t0", "return", "td", ".", "days", "/", "365.25" ]
Calculate the fraction of the year since moon swap.
[ "Calculate", "the", "fraction", "of", "the", "year", "since", "moon", "swap", "." ]
019256424466060babead7edab86736c881b0831
https://github.com/michaelaye/pyciss/blob/019256424466060babead7edab86736c881b0831/pyciss/solitons.py#L12-L16
train
michaelaye/pyciss
pyciss/solitons.py
create_polynoms
def create_polynoms(): """Create and return poly1d objects. Uses the parameters from Morgan to create poly1d objects for calculations. """ fname = pr.resource_filename('pyciss', 'data/soliton_prediction_parameters.csv') res_df = pd.read_csv(fname) polys = {} for resorder, row in zip('65...
python
def create_polynoms(): """Create and return poly1d objects. Uses the parameters from Morgan to create poly1d objects for calculations. """ fname = pr.resource_filename('pyciss', 'data/soliton_prediction_parameters.csv') res_df = pd.read_csv(fname) polys = {} for resorder, row in zip('65...
[ "def", "create_polynoms", "(", ")", ":", "fname", "=", "pr", ".", "resource_filename", "(", "'pyciss'", ",", "'data/soliton_prediction_parameters.csv'", ")", "res_df", "=", "pd", ".", "read_csv", "(", "fname", ")", "polys", "=", "{", "}", "for", "resorder", ...
Create and return poly1d objects. Uses the parameters from Morgan to create poly1d objects for calculations.
[ "Create", "and", "return", "poly1d", "objects", "." ]
019256424466060babead7edab86736c881b0831
https://github.com/michaelaye/pyciss/blob/019256424466060babead7edab86736c881b0831/pyciss/solitons.py#L19-L32
train
michaelaye/pyciss
pyciss/solitons.py
check_for_soliton
def check_for_soliton(img_id): """Workhorse function. Creates the polynom. Calculates radius constraints from attributes in `ringcube` object. Parameters ---------- ringcube : pyciss.ringcube.RingCube A containter class for a ring-projected ISS image file. Returns ------- ...
python
def check_for_soliton(img_id): """Workhorse function. Creates the polynom. Calculates radius constraints from attributes in `ringcube` object. Parameters ---------- ringcube : pyciss.ringcube.RingCube A containter class for a ring-projected ISS image file. Returns ------- ...
[ "def", "check_for_soliton", "(", "img_id", ")", ":", "pm", "=", "io", ".", "PathManager", "(", "img_id", ")", "try", ":", "ringcube", "=", "RingCube", "(", "pm", ".", "cubepath", ")", "except", "FileNotFoundError", ":", "ringcube", "=", "RingCube", "(", ...
Workhorse function. Creates the polynom. Calculates radius constraints from attributes in `ringcube` object. Parameters ---------- ringcube : pyciss.ringcube.RingCube A containter class for a ring-projected ISS image file. Returns ------- dict Dictionary with all solit...
[ "Workhorse", "function", "." ]
019256424466060babead7edab86736c881b0831
https://github.com/michaelaye/pyciss/blob/019256424466060babead7edab86736c881b0831/pyciss/solitons.py#L35-L66
train
koordinates/python-client
koordinates/client.py
Client.get_manager
def get_manager(self, model): """ Return the active manager for the given model. :param model: Model class to look up the manager instance for. :return: Manager instance for the model associated with this client. """ if isinstance(model, six.string_types): # u...
python
def get_manager(self, model): """ Return the active manager for the given model. :param model: Model class to look up the manager instance for. :return: Manager instance for the model associated with this client. """ if isinstance(model, six.string_types): # u...
[ "def", "get_manager", "(", "self", ",", "model", ")", ":", "if", "isinstance", "(", "model", ",", "six", ".", "string_types", ")", ":", "# undocumented string lookup", "for", "k", ",", "m", "in", "self", ".", "_manager_map", ".", "items", "(", ")", ":", ...
Return the active manager for the given model. :param model: Model class to look up the manager instance for. :return: Manager instance for the model associated with this client.
[ "Return", "the", "active", "manager", "for", "the", "given", "model", ".", ":", "param", "model", ":", "Model", "class", "to", "look", "up", "the", "manager", "instance", "for", ".", ":", "return", ":", "Manager", "instance", "for", "the", "model", "asso...
f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252
https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/client.py#L102-L116
train
koordinates/python-client
koordinates/client.py
Client._assemble_headers
def _assemble_headers(self, method, user_headers=None): """ Takes the supplied headers and adds in any which are defined at a client level and then returns the result. :param user_headers: a `dict` containing headers defined at the request level, opt...
python
def _assemble_headers(self, method, user_headers=None): """ Takes the supplied headers and adds in any which are defined at a client level and then returns the result. :param user_headers: a `dict` containing headers defined at the request level, opt...
[ "def", "_assemble_headers", "(", "self", ",", "method", ",", "user_headers", "=", "None", ")", ":", "headers", "=", "copy", ".", "deepcopy", "(", "user_headers", "or", "{", "}", ")", "if", "method", "not", "in", "(", "'GET'", ",", "'HEAD'", ")", ":", ...
Takes the supplied headers and adds in any which are defined at a client level and then returns the result. :param user_headers: a `dict` containing headers defined at the request level, optional. :return: a `dict` instance
[ "Takes", "the", "supplied", "headers", "and", "adds", "in", "any", "which", "are", "defined", "at", "a", "client", "level", "and", "then", "returns", "the", "result", "." ]
f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252
https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/client.py#L119-L136
train
koordinates/python-client
koordinates/client.py
Client.reverse_url
def reverse_url(self, datatype, url, verb='GET', urltype='single', api_version=None): """ Extracts parameters from a populated URL :param datatype: a string identifying the data the url accesses. :param url: the fully-qualified URL to extract parameters from. :param verb: the HT...
python
def reverse_url(self, datatype, url, verb='GET', urltype='single', api_version=None): """ Extracts parameters from a populated URL :param datatype: a string identifying the data the url accesses. :param url: the fully-qualified URL to extract parameters from. :param verb: the HT...
[ "def", "reverse_url", "(", "self", ",", "datatype", ",", "url", ",", "verb", "=", "'GET'", ",", "urltype", "=", "'single'", ",", "api_version", "=", "None", ")", ":", "api_version", "=", "api_version", "or", "'v1'", "templates", "=", "getattr", "(", "sel...
Extracts parameters from a populated URL :param datatype: a string identifying the data the url accesses. :param url: the fully-qualified URL to extract parameters from. :param verb: the HTTP verb needed for use with the url. :param urltype: an adjective used to the nature of the reques...
[ "Extracts", "parameters", "from", "a", "populated", "URL" ]
f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252
https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/client.py#L185-L210
train
koordinates/python-client
koordinates/client.py
Client.get_url
def get_url(self, datatype, verb, urltype, params={}, api_host=None, api_version=None): """Returns a fully formed url :param datatype: a string identifying the data the url will access. :param verb: the HTTP verb needed for use with the url. :param urltype: an adjective used to the natu...
python
def get_url(self, datatype, verb, urltype, params={}, api_host=None, api_version=None): """Returns a fully formed url :param datatype: a string identifying the data the url will access. :param verb: the HTTP verb needed for use with the url. :param urltype: an adjective used to the natu...
[ "def", "get_url", "(", "self", ",", "datatype", ",", "verb", ",", "urltype", ",", "params", "=", "{", "}", ",", "api_host", "=", "None", ",", "api_version", "=", "None", ")", ":", "api_version", "=", "api_version", "or", "'v1'", "api_host", "=", "api_h...
Returns a fully formed url :param datatype: a string identifying the data the url will access. :param verb: the HTTP verb needed for use with the url. :param urltype: an adjective used to the nature of the request. :param \*\*params: substitution variables for the URL. :return: ...
[ "Returns", "a", "fully", "formed", "url" ]
f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252
https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/client.py#L212-L231
train
Unidata/siphon
siphon/cdmr/xarray_support.py
CDMRemoteStore.open_store_variable
def open_store_variable(self, name, var): """Turn CDMRemote variable into something like a numpy.ndarray.""" data = indexing.LazilyOuterIndexedArray(CDMArrayWrapper(name, self)) return Variable(var.dimensions, data, {a: getattr(var, a) for a in var.ncattrs()})
python
def open_store_variable(self, name, var): """Turn CDMRemote variable into something like a numpy.ndarray.""" data = indexing.LazilyOuterIndexedArray(CDMArrayWrapper(name, self)) return Variable(var.dimensions, data, {a: getattr(var, a) for a in var.ncattrs()})
[ "def", "open_store_variable", "(", "self", ",", "name", ",", "var", ")", ":", "data", "=", "indexing", ".", "LazilyOuterIndexedArray", "(", "CDMArrayWrapper", "(", "name", ",", "self", ")", ")", "return", "Variable", "(", "var", ".", "dimensions", ",", "da...
Turn CDMRemote variable into something like a numpy.ndarray.
[ "Turn", "CDMRemote", "variable", "into", "something", "like", "a", "numpy", ".", "ndarray", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/cdmr/xarray_support.py#L52-L55
train
Unidata/siphon
siphon/cdmr/xarray_support.py
CDMRemoteStore.get_attrs
def get_attrs(self): """Get the global attributes from underlying data set.""" return FrozenOrderedDict((a, getattr(self.ds, a)) for a in self.ds.ncattrs())
python
def get_attrs(self): """Get the global attributes from underlying data set.""" return FrozenOrderedDict((a, getattr(self.ds, a)) for a in self.ds.ncattrs())
[ "def", "get_attrs", "(", "self", ")", ":", "return", "FrozenOrderedDict", "(", "(", "a", ",", "getattr", "(", "self", ".", "ds", ",", "a", ")", ")", "for", "a", "in", "self", ".", "ds", ".", "ncattrs", "(", ")", ")" ]
Get the global attributes from underlying data set.
[ "Get", "the", "global", "attributes", "from", "underlying", "data", "set", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/cdmr/xarray_support.py#L62-L64
train
Unidata/siphon
siphon/cdmr/xarray_support.py
CDMRemoteStore.get_dimensions
def get_dimensions(self): """Get the dimensions from underlying data set.""" return FrozenOrderedDict((k, len(v)) for k, v in self.ds.dimensions.items())
python
def get_dimensions(self): """Get the dimensions from underlying data set.""" return FrozenOrderedDict((k, len(v)) for k, v in self.ds.dimensions.items())
[ "def", "get_dimensions", "(", "self", ")", ":", "return", "FrozenOrderedDict", "(", "(", "k", ",", "len", "(", "v", ")", ")", "for", "k", ",", "v", "in", "self", ".", "ds", ".", "dimensions", ".", "items", "(", ")", ")" ]
Get the dimensions from underlying data set.
[ "Get", "the", "dimensions", "from", "underlying", "data", "set", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/cdmr/xarray_support.py#L66-L68
train
Unidata/siphon
siphon/catalog.py
_find_base_tds_url
def _find_base_tds_url(catalog_url): """Identify the base URL of the THREDDS server from the catalog URL. Will retain URL scheme, host, port and username/password when present. """ url_components = urlparse(catalog_url) if url_components.path: return catalog_url.split(url_components.path)[0...
python
def _find_base_tds_url(catalog_url): """Identify the base URL of the THREDDS server from the catalog URL. Will retain URL scheme, host, port and username/password when present. """ url_components = urlparse(catalog_url) if url_components.path: return catalog_url.split(url_components.path)[0...
[ "def", "_find_base_tds_url", "(", "catalog_url", ")", ":", "url_components", "=", "urlparse", "(", "catalog_url", ")", "if", "url_components", ".", "path", ":", "return", "catalog_url", ".", "split", "(", "url_components", ".", "path", ")", "[", "0", "]", "e...
Identify the base URL of the THREDDS server from the catalog URL. Will retain URL scheme, host, port and username/password when present.
[ "Identify", "the", "base", "URL", "of", "the", "THREDDS", "server", "from", "the", "catalog", "URL", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/catalog.py#L790-L799
train
Unidata/siphon
siphon/catalog.py
DatasetCollection.filter_time_nearest
def filter_time_nearest(self, time, regex=None): """Filter keys for an item closest to the desired time. Loops over all keys in the collection and uses `regex` to extract and build `datetime`s. The collection of `datetime`s is compared to `start` and the value that has a `datetime` clos...
python
def filter_time_nearest(self, time, regex=None): """Filter keys for an item closest to the desired time. Loops over all keys in the collection and uses `regex` to extract and build `datetime`s. The collection of `datetime`s is compared to `start` and the value that has a `datetime` clos...
[ "def", "filter_time_nearest", "(", "self", ",", "time", ",", "regex", "=", "None", ")", ":", "return", "min", "(", "self", ".", "_get_datasets_with_times", "(", "regex", ")", ",", "key", "=", "lambda", "i", ":", "abs", "(", "(", "i", "[", "0", "]", ...
Filter keys for an item closest to the desired time. Loops over all keys in the collection and uses `regex` to extract and build `datetime`s. The collection of `datetime`s is compared to `start` and the value that has a `datetime` closest to that requested is returned.If none of the keys in the...
[ "Filter", "keys", "for", "an", "item", "closest", "to", "the", "desired", "time", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/catalog.py#L74-L100
train
Unidata/siphon
siphon/catalog.py
DatasetCollection.filter_time_range
def filter_time_range(self, start, end, regex=None): """Filter keys for all items within the desired time range. Loops over all keys in the collection and uses `regex` to extract and build `datetime`s. From the collection of `datetime`s, all values within `start` and `end` (inclusive) a...
python
def filter_time_range(self, start, end, regex=None): """Filter keys for all items within the desired time range. Loops over all keys in the collection and uses `regex` to extract and build `datetime`s. From the collection of `datetime`s, all values within `start` and `end` (inclusive) a...
[ "def", "filter_time_range", "(", "self", ",", "start", ",", "end", ",", "regex", "=", "None", ")", ":", "return", "[", "item", "[", "-", "1", "]", "for", "item", "in", "self", ".", "_get_datasets_with_times", "(", "regex", ")", "if", "start", "<=", "...
Filter keys for all items within the desired time range. Loops over all keys in the collection and uses `regex` to extract and build `datetime`s. From the collection of `datetime`s, all values within `start` and `end` (inclusive) are returned. If none of the keys in the collection match the reg...
[ "Filter", "keys", "for", "all", "items", "within", "the", "desired", "time", "range", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/catalog.py#L102-L129
train
Unidata/siphon
siphon/catalog.py
CaseInsensitiveDict.pop
def pop(self, key, *args, **kwargs): """Remove and return the value associated with case-insensitive ``key``.""" return super(CaseInsensitiveDict, self).pop(CaseInsensitiveStr(key))
python
def pop(self, key, *args, **kwargs): """Remove and return the value associated with case-insensitive ``key``.""" return super(CaseInsensitiveDict, self).pop(CaseInsensitiveStr(key))
[ "def", "pop", "(", "self", ",", "key", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "super", "(", "CaseInsensitiveDict", ",", "self", ")", ".", "pop", "(", "CaseInsensitiveStr", "(", "key", ")", ")" ]
Remove and return the value associated with case-insensitive ``key``.
[ "Remove", "and", "return", "the", "value", "associated", "with", "case", "-", "insensitive", "key", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/catalog.py#L210-L212
train
Unidata/siphon
siphon/catalog.py
CaseInsensitiveDict._keys_to_lower
def _keys_to_lower(self): """Convert key set to lowercase.""" for k in list(self.keys()): val = super(CaseInsensitiveDict, self).__getitem__(k) super(CaseInsensitiveDict, self).__delitem__(k) self.__setitem__(CaseInsensitiveStr(k), val)
python
def _keys_to_lower(self): """Convert key set to lowercase.""" for k in list(self.keys()): val = super(CaseInsensitiveDict, self).__getitem__(k) super(CaseInsensitiveDict, self).__delitem__(k) self.__setitem__(CaseInsensitiveStr(k), val)
[ "def", "_keys_to_lower", "(", "self", ")", ":", "for", "k", "in", "list", "(", "self", ".", "keys", "(", ")", ")", ":", "val", "=", "super", "(", "CaseInsensitiveDict", ",", "self", ")", ".", "__getitem__", "(", "k", ")", "super", "(", "CaseInsensiti...
Convert key set to lowercase.
[ "Convert", "key", "set", "to", "lowercase", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/catalog.py#L214-L219
train
Unidata/siphon
siphon/catalog.py
Dataset.resolve_url
def resolve_url(self, catalog_url): """Resolve the url of the dataset when reading latest.xml. Parameters ---------- catalog_url : str The catalog url to be resolved """ if catalog_url != '': resolver_base = catalog_url.split('catalog.xml')[0] ...
python
def resolve_url(self, catalog_url): """Resolve the url of the dataset when reading latest.xml. Parameters ---------- catalog_url : str The catalog url to be resolved """ if catalog_url != '': resolver_base = catalog_url.split('catalog.xml')[0] ...
[ "def", "resolve_url", "(", "self", ",", "catalog_url", ")", ":", "if", "catalog_url", "!=", "''", ":", "resolver_base", "=", "catalog_url", ".", "split", "(", "'catalog.xml'", ")", "[", "0", "]", "resolver_url", "=", "resolver_base", "+", "self", ".", "url...
Resolve the url of the dataset when reading latest.xml. Parameters ---------- catalog_url : str The catalog url to be resolved
[ "Resolve", "the", "url", "of", "the", "dataset", "when", "reading", "latest", ".", "xml", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/catalog.py#L477-L509
train
Unidata/siphon
siphon/catalog.py
Dataset.make_access_urls
def make_access_urls(self, catalog_url, all_services, metadata=None): """Make fully qualified urls for the access methods enabled on the dataset. Parameters ---------- catalog_url : str The top level server url all_services : List[SimpleService] list of :...
python
def make_access_urls(self, catalog_url, all_services, metadata=None): """Make fully qualified urls for the access methods enabled on the dataset. Parameters ---------- catalog_url : str The top level server url all_services : List[SimpleService] list of :...
[ "def", "make_access_urls", "(", "self", ",", "catalog_url", ",", "all_services", ",", "metadata", "=", "None", ")", ":", "all_service_dict", "=", "CaseInsensitiveDict", "(", "{", "}", ")", "for", "service", "in", "all_services", ":", "all_service_dict", "[", "...
Make fully qualified urls for the access methods enabled on the dataset. Parameters ---------- catalog_url : str The top level server url all_services : List[SimpleService] list of :class:`SimpleService` objects associated with the dataset metadata : dict...
[ "Make", "fully", "qualified", "urls", "for", "the", "access", "methods", "enabled", "on", "the", "dataset", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/catalog.py#L511-L560
train
Unidata/siphon
siphon/catalog.py
Dataset.add_access_element_info
def add_access_element_info(self, access_element): """Create an access method from a catalog element.""" service_name = access_element.attrib['serviceName'] url_path = access_element.attrib['urlPath'] self.access_element_info[service_name] = url_path
python
def add_access_element_info(self, access_element): """Create an access method from a catalog element.""" service_name = access_element.attrib['serviceName'] url_path = access_element.attrib['urlPath'] self.access_element_info[service_name] = url_path
[ "def", "add_access_element_info", "(", "self", ",", "access_element", ")", ":", "service_name", "=", "access_element", ".", "attrib", "[", "'serviceName'", "]", "url_path", "=", "access_element", ".", "attrib", "[", "'urlPath'", "]", "self", ".", "access_element_i...
Create an access method from a catalog element.
[ "Create", "an", "access", "method", "from", "a", "catalog", "element", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/catalog.py#L562-L566
train
Unidata/siphon
siphon/catalog.py
Dataset.download
def download(self, filename=None): """Download the dataset to a local file. Parameters ---------- filename : str, optional The full path to which the dataset will be saved """ if filename is None: filename = self.name with self.remote_ope...
python
def download(self, filename=None): """Download the dataset to a local file. Parameters ---------- filename : str, optional The full path to which the dataset will be saved """ if filename is None: filename = self.name with self.remote_ope...
[ "def", "download", "(", "self", ",", "filename", "=", "None", ")", ":", "if", "filename", "is", "None", ":", "filename", "=", "self", ".", "name", "with", "self", ".", "remote_open", "(", ")", "as", "infile", ":", "with", "open", "(", "filename", ","...
Download the dataset to a local file. Parameters ---------- filename : str, optional The full path to which the dataset will be saved
[ "Download", "the", "dataset", "to", "a", "local", "file", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/catalog.py#L568-L581
train
Unidata/siphon
siphon/catalog.py
Dataset.remote_access
def remote_access(self, service=None, use_xarray=None): """Access the remote dataset. Open the remote dataset and get a netCDF4-compatible `Dataset` object providing index-based subsetting capabilities. Parameters ---------- service : str, optional The name ...
python
def remote_access(self, service=None, use_xarray=None): """Access the remote dataset. Open the remote dataset and get a netCDF4-compatible `Dataset` object providing index-based subsetting capabilities. Parameters ---------- service : str, optional The name ...
[ "def", "remote_access", "(", "self", ",", "service", "=", "None", ",", "use_xarray", "=", "None", ")", ":", "if", "service", "is", "None", ":", "service", "=", "'CdmRemote'", "if", "'CdmRemote'", "in", "self", ".", "access_urls", "else", "'OPENDAP'", "if",...
Access the remote dataset. Open the remote dataset and get a netCDF4-compatible `Dataset` object providing index-based subsetting capabilities. Parameters ---------- service : str, optional The name of the service to use for access to the dataset, either ...
[ "Access", "the", "remote", "dataset", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/catalog.py#L596-L620
train
Unidata/siphon
siphon/catalog.py
Dataset.subset
def subset(self, service=None): """Subset the dataset. Open the remote dataset and get a client for talking to ``service``. Parameters ---------- service : str, optional The name of the service for subsetting the dataset. Defaults to 'NetcdfSubset' or 'N...
python
def subset(self, service=None): """Subset the dataset. Open the remote dataset and get a client for talking to ``service``. Parameters ---------- service : str, optional The name of the service for subsetting the dataset. Defaults to 'NetcdfSubset' or 'N...
[ "def", "subset", "(", "self", ",", "service", "=", "None", ")", ":", "if", "service", "is", "None", ":", "for", "serviceName", "in", "self", ".", "ncssServiceNames", ":", "if", "serviceName", "in", "self", ".", "access_urls", ":", "service", "=", "servic...
Subset the dataset. Open the remote dataset and get a client for talking to ``service``. Parameters ---------- service : str, optional The name of the service for subsetting the dataset. Defaults to 'NetcdfSubset' or 'NetcdfServer', in that order, depending on t...
[ "Subset", "the", "dataset", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/catalog.py#L622-L650
train
Unidata/siphon
siphon/catalog.py
Dataset.access_with_service
def access_with_service(self, service, use_xarray=None): """Access the dataset using a particular service. Return an Python object capable of communicating with the server using the particular service. For instance, for 'HTTPServer' this is a file-like object capable of HTTP communicati...
python
def access_with_service(self, service, use_xarray=None): """Access the dataset using a particular service. Return an Python object capable of communicating with the server using the particular service. For instance, for 'HTTPServer' this is a file-like object capable of HTTP communicati...
[ "def", "access_with_service", "(", "self", ",", "service", ",", "use_xarray", "=", "None", ")", ":", "service", "=", "CaseInsensitiveStr", "(", "service", ")", "if", "service", "==", "'CdmRemote'", ":", "if", "use_xarray", ":", "from", ".", "cdmr", ".", "x...
Access the dataset using a particular service. Return an Python object capable of communicating with the server using the particular service. For instance, for 'HTTPServer' this is a file-like object capable of HTTP communication; for OPENDAP this is a netCDF4 dataset. Parameters ...
[ "Access", "the", "dataset", "using", "a", "particular", "service", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/catalog.py#L652-L705
train
Unidata/siphon
siphon/_tools.py
get_wind_components
def get_wind_components(speed, wdir): r"""Calculate the U, V wind vector components from the speed and direction. Parameters ---------- speed : array_like The wind speed (magnitude) wdir : array_like The wind direction, specified as the direction from which the wind is blowi...
python
def get_wind_components(speed, wdir): r"""Calculate the U, V wind vector components from the speed and direction. Parameters ---------- speed : array_like The wind speed (magnitude) wdir : array_like The wind direction, specified as the direction from which the wind is blowi...
[ "def", "get_wind_components", "(", "speed", ",", "wdir", ")", ":", "u", "=", "-", "speed", "*", "np", ".", "sin", "(", "wdir", ")", "v", "=", "-", "speed", "*", "np", ".", "cos", "(", "wdir", ")", "return", "u", ",", "v" ]
r"""Calculate the U, V wind vector components from the speed and direction. Parameters ---------- speed : array_like The wind speed (magnitude) wdir : array_like The wind direction, specified as the direction from which the wind is blowing, with 0 being North. Returns -...
[ "r", "Calculate", "the", "U", "V", "wind", "vector", "components", "from", "the", "speed", "and", "direction", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/_tools.py#L9-L29
train
Unidata/siphon
siphon/cdmr/cdmremotefeature.py
CDMRemoteFeature._get_metadata
def _get_metadata(self): """Get header information and store as metadata for the endpoint.""" self.metadata = self.fetch_header() self.variables = {g.name for g in self.metadata.grids}
python
def _get_metadata(self): """Get header information and store as metadata for the endpoint.""" self.metadata = self.fetch_header() self.variables = {g.name for g in self.metadata.grids}
[ "def", "_get_metadata", "(", "self", ")", ":", "self", ".", "metadata", "=", "self", ".", "fetch_header", "(", ")", "self", ".", "variables", "=", "{", "g", ".", "name", "for", "g", "in", "self", ".", "metadata", ".", "grids", "}" ]
Get header information and store as metadata for the endpoint.
[ "Get", "header", "information", "and", "store", "as", "metadata", "for", "the", "endpoint", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/cdmr/cdmremotefeature.py#L20-L23
train
Unidata/siphon
siphon/cdmr/cdmremotefeature.py
CDMRemoteFeature.fetch_header
def fetch_header(self): """Make a header request to the endpoint.""" query = self.query().add_query_parameter(req='header') return self._parse_messages(self.get_query(query).content)[0]
python
def fetch_header(self): """Make a header request to the endpoint.""" query = self.query().add_query_parameter(req='header') return self._parse_messages(self.get_query(query).content)[0]
[ "def", "fetch_header", "(", "self", ")", ":", "query", "=", "self", ".", "query", "(", ")", ".", "add_query_parameter", "(", "req", "=", "'header'", ")", "return", "self", ".", "_parse_messages", "(", "self", ".", "get_query", "(", "query", ")", ".", "...
Make a header request to the endpoint.
[ "Make", "a", "header", "request", "to", "the", "endpoint", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/cdmr/cdmremotefeature.py#L25-L28
train
Unidata/siphon
siphon/cdmr/cdmremotefeature.py
CDMRemoteFeature.fetch_feature_type
def fetch_feature_type(self): """Request the featureType from the endpoint.""" query = self.query().add_query_parameter(req='featureType') return self.get_query(query).content
python
def fetch_feature_type(self): """Request the featureType from the endpoint.""" query = self.query().add_query_parameter(req='featureType') return self.get_query(query).content
[ "def", "fetch_feature_type", "(", "self", ")", ":", "query", "=", "self", ".", "query", "(", ")", ".", "add_query_parameter", "(", "req", "=", "'featureType'", ")", "return", "self", ".", "get_query", "(", "query", ")", ".", "content" ]
Request the featureType from the endpoint.
[ "Request", "the", "featureType", "from", "the", "endpoint", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/cdmr/cdmremotefeature.py#L30-L33
train
Unidata/siphon
siphon/cdmr/cdmremotefeature.py
CDMRemoteFeature.fetch_coords
def fetch_coords(self, query): """Pull down coordinate data from the endpoint.""" q = query.add_query_parameter(req='coord') return self._parse_messages(self.get_query(q).content)
python
def fetch_coords(self, query): """Pull down coordinate data from the endpoint.""" q = query.add_query_parameter(req='coord') return self._parse_messages(self.get_query(q).content)
[ "def", "fetch_coords", "(", "self", ",", "query", ")", ":", "q", "=", "query", ".", "add_query_parameter", "(", "req", "=", "'coord'", ")", "return", "self", ".", "_parse_messages", "(", "self", ".", "get_query", "(", "q", ")", ".", "content", ")" ]
Pull down coordinate data from the endpoint.
[ "Pull", "down", "coordinate", "data", "from", "the", "endpoint", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/cdmr/cdmremotefeature.py#L35-L38
train
Unidata/siphon
siphon/simplewebservice/igra2.py
IGRAUpperAir.request_data
def request_data(cls, time, site_id, derived=False): """Retreive IGRA version 2 data for one station. Parameters -------- site_id : str 11-character IGRA2 station identifier. time : datetime The date and time of the desired observation. If list of two tim...
python
def request_data(cls, time, site_id, derived=False): """Retreive IGRA version 2 data for one station. Parameters -------- site_id : str 11-character IGRA2 station identifier. time : datetime The date and time of the desired observation. If list of two tim...
[ "def", "request_data", "(", "cls", ",", "time", ",", "site_id", ",", "derived", "=", "False", ")", ":", "igra2", "=", "cls", "(", ")", "# Set parameters for data query", "if", "derived", ":", "igra2", ".", "ftpsite", "=", "igra2", ".", "ftpsite", "+", "'...
Retreive IGRA version 2 data for one station. Parameters -------- site_id : str 11-character IGRA2 station identifier. time : datetime The date and time of the desired observation. If list of two times is given, dataframes for all dates within the two ...
[ "Retreive", "IGRA", "version", "2", "data", "for", "one", "station", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/simplewebservice/igra2.py#L35-L72
train
Unidata/siphon
siphon/simplewebservice/igra2.py
IGRAUpperAir._get_data
def _get_data(self): """Process the IGRA2 text file for observations at site_id matching time. Return: ------- :class: `pandas.DataFrame` containing the body data. :class: `pandas.DataFrame` containing the header data. """ # Split the list of times into b...
python
def _get_data(self): """Process the IGRA2 text file for observations at site_id matching time. Return: ------- :class: `pandas.DataFrame` containing the body data. :class: `pandas.DataFrame` containing the header data. """ # Split the list of times into b...
[ "def", "_get_data", "(", "self", ")", ":", "# Split the list of times into begin and end dates. If only", "# one date is supplied, set both begin and end dates equal to that date.", "body", ",", "header", ",", "dates_long", ",", "dates", "=", "self", ".", "_get_data_raw", "(", ...
Process the IGRA2 text file for observations at site_id matching time. Return: ------- :class: `pandas.DataFrame` containing the body data. :class: `pandas.DataFrame` containing the header data.
[ "Process", "the", "IGRA2", "text", "file", "for", "observations", "at", "site_id", "matching", "time", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/simplewebservice/igra2.py#L74-L97
train
Unidata/siphon
siphon/simplewebservice/igra2.py
IGRAUpperAir._get_data_raw
def _get_data_raw(self): """Download observations matching the time range. Returns a tuple with a string for the body, string for the headers, and a list of dates. """ # Import need to be here so we can monkeypatch urlopen for testing and avoid # downloading live data fo...
python
def _get_data_raw(self): """Download observations matching the time range. Returns a tuple with a string for the body, string for the headers, and a list of dates. """ # Import need to be here so we can monkeypatch urlopen for testing and avoid # downloading live data fo...
[ "def", "_get_data_raw", "(", "self", ")", ":", "# Import need to be here so we can monkeypatch urlopen for testing and avoid", "# downloading live data for testing", "try", ":", "from", "urllib", ".", "request", "import", "urlopen", "except", "ImportError", ":", "from", "urll...
Download observations matching the time range. Returns a tuple with a string for the body, string for the headers, and a list of dates.
[ "Download", "observations", "matching", "the", "time", "range", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/simplewebservice/igra2.py#L99-L119
train
Unidata/siphon
siphon/simplewebservice/igra2.py
IGRAUpperAir._select_date_range
def _select_date_range(self, lines): """Identify lines containing headers within the range begin_date to end_date. Parameters ----- lines: list list of lines from the IGRA2 data file. """ headers = [] num_lev = [] dates = [] # Get in...
python
def _select_date_range(self, lines): """Identify lines containing headers within the range begin_date to end_date. Parameters ----- lines: list list of lines from the IGRA2 data file. """ headers = [] num_lev = [] dates = [] # Get in...
[ "def", "_select_date_range", "(", "self", ",", "lines", ")", ":", "headers", "=", "[", "]", "num_lev", "=", "[", "]", "dates", "=", "[", "]", "# Get indices of headers, and make a list of dates and num_lev", "for", "idx", ",", "line", "in", "enumerate", "(", "...
Identify lines containing headers within the range begin_date to end_date. Parameters ----- lines: list list of lines from the IGRA2 data file.
[ "Identify", "lines", "containing", "headers", "within", "the", "range", "begin_date", "to", "end_date", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/simplewebservice/igra2.py#L121-L174
train
Unidata/siphon
siphon/simplewebservice/igra2.py
IGRAUpperAir._get_fwf_params
def _get_fwf_params(self): """Produce a dictionary with names, colspecs, and dtype for IGRA2 data. Returns a dict with entries 'body' and 'header'. """ def _cdec(power=1): """Make a function to convert string 'value*10^power' to float.""" def _cdec_power(val): ...
python
def _get_fwf_params(self): """Produce a dictionary with names, colspecs, and dtype for IGRA2 data. Returns a dict with entries 'body' and 'header'. """ def _cdec(power=1): """Make a function to convert string 'value*10^power' to float.""" def _cdec_power(val): ...
[ "def", "_get_fwf_params", "(", "self", ")", ":", "def", "_cdec", "(", "power", "=", "1", ")", ":", "\"\"\"Make a function to convert string 'value*10^power' to float.\"\"\"", "def", "_cdec_power", "(", "val", ")", ":", "if", "val", "in", "[", "'-9999'", ",", "'-...
Produce a dictionary with names, colspecs, and dtype for IGRA2 data. Returns a dict with entries 'body' and 'header'.
[ "Produce", "a", "dictionary", "with", "names", "colspecs", "and", "dtype", "for", "IGRA2", "data", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/simplewebservice/igra2.py#L176-L356
train
Unidata/siphon
siphon/simplewebservice/igra2.py
IGRAUpperAir._clean_body_df
def _clean_body_df(self, df): """Format the dataframe, remove empty rows, and add units attribute.""" if self.suffix == '-drvd.txt': df = df.dropna(subset=('temperature', 'reported_relative_humidity', 'u_wind', 'v_wind'), how='all').reset_index(drop=True) ...
python
def _clean_body_df(self, df): """Format the dataframe, remove empty rows, and add units attribute.""" if self.suffix == '-drvd.txt': df = df.dropna(subset=('temperature', 'reported_relative_humidity', 'u_wind', 'v_wind'), how='all').reset_index(drop=True) ...
[ "def", "_clean_body_df", "(", "self", ",", "df", ")", ":", "if", "self", ".", "suffix", "==", "'-drvd.txt'", ":", "df", "=", "df", ".", "dropna", "(", "subset", "=", "(", "'temperature'", ",", "'reported_relative_humidity'", ",", "'u_wind'", ",", "'v_wind'...
Format the dataframe, remove empty rows, and add units attribute.
[ "Format", "the", "dataframe", "remove", "empty", "rows", "and", "add", "units", "attribute", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/simplewebservice/igra2.py#L358-L407
train
Unidata/siphon
siphon/simplewebservice/igra2.py
IGRAUpperAir._clean_header_df
def _clean_header_df(self, df): """Format the header dataframe and add units.""" if self.suffix == '-drvd.txt': df.units = {'release_time': 'second', 'precipitable_water': 'millimeter', 'inv_pressure': 'hPa', 'inv_height...
python
def _clean_header_df(self, df): """Format the header dataframe and add units.""" if self.suffix == '-drvd.txt': df.units = {'release_time': 'second', 'precipitable_water': 'millimeter', 'inv_pressure': 'hPa', 'inv_height...
[ "def", "_clean_header_df", "(", "self", ",", "df", ")", ":", "if", "self", ".", "suffix", "==", "'-drvd.txt'", ":", "df", ".", "units", "=", "{", "'release_time'", ":", "'second'", ",", "'precipitable_water'", ":", "'millimeter'", ",", "'inv_pressure'", ":",...
Format the header dataframe and add units.
[ "Format", "the", "header", "dataframe", "and", "add", "units", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/simplewebservice/igra2.py#L409-L439
train
Unidata/siphon
siphon/simplewebservice/ndbc.py
NDBC.realtime_observations
def realtime_observations(cls, buoy, data_type='txt'): """Retrieve the realtime buoy data from NDBC. Parameters ---------- buoy : str Name of buoy data_type : str Type of data requested, must be one of 'txt' standard meteorological data ...
python
def realtime_observations(cls, buoy, data_type='txt'): """Retrieve the realtime buoy data from NDBC. Parameters ---------- buoy : str Name of buoy data_type : str Type of data requested, must be one of 'txt' standard meteorological data ...
[ "def", "realtime_observations", "(", "cls", ",", "buoy", ",", "data_type", "=", "'txt'", ")", ":", "endpoint", "=", "cls", "(", ")", "parsers", "=", "{", "'txt'", ":", "endpoint", ".", "_parse_met", ",", "'drift'", ":", "endpoint", ".", "_parse_drift", "...
Retrieve the realtime buoy data from NDBC. Parameters ---------- buoy : str Name of buoy data_type : str Type of data requested, must be one of 'txt' standard meteorological data 'drift' meteorological data from drifting buoys and limited ...
[ "Retrieve", "the", "realtime", "buoy", "data", "from", "NDBC", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/simplewebservice/ndbc.py#L26-L67
train
Unidata/siphon
siphon/simplewebservice/ndbc.py
NDBC._parse_met
def _parse_met(content): """Parse standard meteorological data from NDBC buoys. Parameters ---------- content : str Data to parse Returns ------- :class:`pandas.DataFrame` containing the data """ col_names = ['year', 'month', 'da...
python
def _parse_met(content): """Parse standard meteorological data from NDBC buoys. Parameters ---------- content : str Data to parse Returns ------- :class:`pandas.DataFrame` containing the data """ col_names = ['year', 'month', 'da...
[ "def", "_parse_met", "(", "content", ")", ":", "col_names", "=", "[", "'year'", ",", "'month'", ",", "'day'", ",", "'hour'", ",", "'minute'", ",", "'wind_direction'", ",", "'wind_speed'", ",", "'wind_gust'", ",", "'wave_height'", ",", "'dominant_wave_period'", ...
Parse standard meteorological data from NDBC buoys. Parameters ---------- content : str Data to parse Returns ------- :class:`pandas.DataFrame` containing the data
[ "Parse", "standard", "meteorological", "data", "from", "NDBC", "buoys", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/simplewebservice/ndbc.py#L70-L111
train
Unidata/siphon
siphon/simplewebservice/ndbc.py
NDBC._parse_supl
def _parse_supl(content): """Parse supplemental measurements data. Parameters ---------- content : str Data to parse Returns ------- :class:`pandas.DataFrame` containing the data """ col_names = ['year', 'month', 'day', 'hour', '...
python
def _parse_supl(content): """Parse supplemental measurements data. Parameters ---------- content : str Data to parse Returns ------- :class:`pandas.DataFrame` containing the data """ col_names = ['year', 'month', 'day', 'hour', '...
[ "def", "_parse_supl", "(", "content", ")", ":", "col_names", "=", "[", "'year'", ",", "'month'", ",", "'day'", ",", "'hour'", ",", "'minute'", ",", "'hourly_low_pressure'", ",", "'hourly_low_pressure_time'", ",", "'hourly_high_wind'", ",", "'hourly_high_wind_directi...
Parse supplemental measurements data. Parameters ---------- content : str Data to parse Returns ------- :class:`pandas.DataFrame` containing the data
[ "Parse", "supplemental", "measurements", "data", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/simplewebservice/ndbc.py#L369-L414
train
Unidata/siphon
siphon/simplewebservice/ndbc.py
NDBC._check_if_url_valid
def _check_if_url_valid(url): """Check if a url is valid (returns 200) or not. Parameters ---------- url : str URL to check Returns ------- bool if url is valid """ r = requests.head(url) if r.status_code == 200: ...
python
def _check_if_url_valid(url): """Check if a url is valid (returns 200) or not. Parameters ---------- url : str URL to check Returns ------- bool if url is valid """ r = requests.head(url) if r.status_code == 200: ...
[ "def", "_check_if_url_valid", "(", "url", ")", ":", "r", "=", "requests", ".", "head", "(", "url", ")", "if", "r", ".", "status_code", "==", "200", ":", "return", "True", "else", ":", "return", "False" ]
Check if a url is valid (returns 200) or not. Parameters ---------- url : str URL to check Returns ------- bool if url is valid
[ "Check", "if", "a", "url", "is", "valid", "(", "returns", "200", ")", "or", "not", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/simplewebservice/ndbc.py#L462-L479
train
Unidata/siphon
siphon/simplewebservice/ndbc.py
NDBC.buoy_data_types
def buoy_data_types(cls, buoy): """Determine which types of data are available for a given buoy. Parameters ---------- buoy : str Buoy name Returns ------- dict of valid file extensions and their descriptions """ endpoint = cls()...
python
def buoy_data_types(cls, buoy): """Determine which types of data are available for a given buoy. Parameters ---------- buoy : str Buoy name Returns ------- dict of valid file extensions and their descriptions """ endpoint = cls()...
[ "def", "buoy_data_types", "(", "cls", ",", "buoy", ")", ":", "endpoint", "=", "cls", "(", ")", "file_types", "=", "{", "'txt'", ":", "'standard meteorological data'", ",", "'drift'", ":", "'meteorological data from drifting buoys and limited moored'", "'buoy data mainly...
Determine which types of data are available for a given buoy. Parameters ---------- buoy : str Buoy name Returns ------- dict of valid file extensions and their descriptions
[ "Determine", "which", "types", "of", "data", "are", "available", "for", "a", "given", "buoy", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/simplewebservice/ndbc.py#L482-L518
train
Unidata/siphon
siphon/simplewebservice/ndbc.py
NDBC.raw_buoy_data
def raw_buoy_data(cls, buoy, data_type='txt'): """Retrieve the raw buoy data contents from NDBC. Parameters ---------- buoy : str Name of buoy data_type : str Type of data requested, must be one of 'txt' standard meteorological data ...
python
def raw_buoy_data(cls, buoy, data_type='txt'): """Retrieve the raw buoy data contents from NDBC. Parameters ---------- buoy : str Name of buoy data_type : str Type of data requested, must be one of 'txt' standard meteorological data ...
[ "def", "raw_buoy_data", "(", "cls", ",", "buoy", ",", "data_type", "=", "'txt'", ")", ":", "endpoint", "=", "cls", "(", ")", "resp", "=", "endpoint", ".", "get_path", "(", "'data/realtime2/{}.{}'", ".", "format", "(", "buoy", ",", "data_type", ")", ")", ...
Retrieve the raw buoy data contents from NDBC. Parameters ---------- buoy : str Name of buoy data_type : str Type of data requested, must be one of 'txt' standard meteorological data 'drift' meteorological data from drifting buoys and lim...
[ "Retrieve", "the", "raw", "buoy", "data", "contents", "from", "NDBC", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/simplewebservice/ndbc.py#L521-L556
train
Unidata/siphon
siphon/http_util.py
HTTPSessionManager.create_session
def create_session(self): """Create a new HTTP session with our user-agent set. Returns ------- session : requests.Session The created session See Also -------- urlopen, set_session_options """ ret = requests.Session() ret.he...
python
def create_session(self): """Create a new HTTP session with our user-agent set. Returns ------- session : requests.Session The created session See Also -------- urlopen, set_session_options """ ret = requests.Session() ret.he...
[ "def", "create_session", "(", "self", ")", ":", "ret", "=", "requests", ".", "Session", "(", ")", "ret", ".", "headers", "[", "'User-Agent'", "]", "=", "self", ".", "user_agent", "for", "k", ",", "v", "in", "self", ".", "options", ".", "items", "(", ...
Create a new HTTP session with our user-agent set. Returns ------- session : requests.Session The created session See Also -------- urlopen, set_session_options
[ "Create", "a", "new", "HTTP", "session", "with", "our", "user", "-", "agent", "set", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/http_util.py#L71-L88
train
Unidata/siphon
siphon/http_util.py
HTTPSessionManager.urlopen
def urlopen(self, url, **kwargs): """GET a file-like object for a URL using HTTP. This is a thin wrapper around :meth:`requests.Session.get` that returns a file-like object wrapped around the resulting content. Parameters ---------- url : str The URL to requ...
python
def urlopen(self, url, **kwargs): """GET a file-like object for a URL using HTTP. This is a thin wrapper around :meth:`requests.Session.get` that returns a file-like object wrapped around the resulting content. Parameters ---------- url : str The URL to requ...
[ "def", "urlopen", "(", "self", ",", "url", ",", "*", "*", "kwargs", ")", ":", "return", "BytesIO", "(", "self", ".", "create_session", "(", ")", ".", "get", "(", "url", ",", "*", "*", "kwargs", ")", ".", "content", ")" ]
GET a file-like object for a URL using HTTP. This is a thin wrapper around :meth:`requests.Session.get` that returns a file-like object wrapped around the resulting content. Parameters ---------- url : str The URL to request kwargs : arbitrary keyword argum...
[ "GET", "a", "file", "-", "like", "object", "for", "a", "URL", "using", "HTTP", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/http_util.py#L90-L114
train
Unidata/siphon
siphon/http_util.py
DataQuery.lonlat_box
def lonlat_box(self, west, east, south, north): """Add a latitude/longitude bounding box to the query. This adds a request for a spatial bounding box, bounded by ('north', 'south') for latitude and ('east', 'west') for the longitude. This modifies the query in-place, but returns `self` ...
python
def lonlat_box(self, west, east, south, north): """Add a latitude/longitude bounding box to the query. This adds a request for a spatial bounding box, bounded by ('north', 'south') for latitude and ('east', 'west') for the longitude. This modifies the query in-place, but returns `self` ...
[ "def", "lonlat_box", "(", "self", ",", "west", ",", "east", ",", "south", ",", "north", ")", ":", "self", ".", "_set_query", "(", "self", ".", "spatial_query", ",", "west", "=", "west", ",", "east", "=", "east", ",", "south", "=", "south", ",", "no...
Add a latitude/longitude bounding box to the query. This adds a request for a spatial bounding box, bounded by ('north', 'south') for latitude and ('east', 'west') for the longitude. This modifies the query in-place, but returns `self` so that multiple queries can be chained together on...
[ "Add", "a", "latitude", "/", "longitude", "bounding", "box", "to", "the", "query", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/http_util.py#L197-L226
train
Unidata/siphon
siphon/http_util.py
DataQuery.lonlat_point
def lonlat_point(self, lon, lat): """Add a latitude/longitude point to the query. This adds a request for a (`lon`, `lat`) point. This modifies the query in-place, but returns `self` so that multiple queries can be chained together on one line. This replaces any existing spatia...
python
def lonlat_point(self, lon, lat): """Add a latitude/longitude point to the query. This adds a request for a (`lon`, `lat`) point. This modifies the query in-place, but returns `self` so that multiple queries can be chained together on one line. This replaces any existing spatia...
[ "def", "lonlat_point", "(", "self", ",", "lon", ",", "lat", ")", ":", "self", ".", "_set_query", "(", "self", ".", "spatial_query", ",", "longitude", "=", "lon", ",", "latitude", "=", "lat", ")", "return", "self" ]
Add a latitude/longitude point to the query. This adds a request for a (`lon`, `lat`) point. This modifies the query in-place, but returns `self` so that multiple queries can be chained together on one line. This replaces any existing spatial queries that have been set. Parame...
[ "Add", "a", "latitude", "/", "longitude", "point", "to", "the", "query", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/http_util.py#L228-L251
train
Unidata/siphon
siphon/http_util.py
DataQuery.time
def time(self, time): """Add a request for a specific time to the query. This modifies the query in-place, but returns `self` so that multiple queries can be chained together on one line. This replaces any existing temporal queries that have been set. Parameters ------...
python
def time(self, time): """Add a request for a specific time to the query. This modifies the query in-place, but returns `self` so that multiple queries can be chained together on one line. This replaces any existing temporal queries that have been set. Parameters ------...
[ "def", "time", "(", "self", ",", "time", ")", ":", "self", ".", "_set_query", "(", "self", ".", "time_query", ",", "time", "=", "self", ".", "_format_time", "(", "time", ")", ")", "return", "self" ]
Add a request for a specific time to the query. This modifies the query in-place, but returns `self` so that multiple queries can be chained together on one line. This replaces any existing temporal queries that have been set. Parameters ---------- time : datetime.date...
[ "Add", "a", "request", "for", "a", "specific", "time", "to", "the", "query", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/http_util.py#L277-L297
train
Unidata/siphon
siphon/http_util.py
DataQuery.time_range
def time_range(self, start, end): """Add a request for a time range to the query. This modifies the query in-place, but returns `self` so that multiple queries can be chained together on one line. This replaces any existing temporal queries that have been set. Parameters ...
python
def time_range(self, start, end): """Add a request for a time range to the query. This modifies the query in-place, but returns `self` so that multiple queries can be chained together on one line. This replaces any existing temporal queries that have been set. Parameters ...
[ "def", "time_range", "(", "self", ",", "start", ",", "end", ")", ":", "self", ".", "_set_query", "(", "self", ".", "time_query", ",", "time_start", "=", "self", ".", "_format_time", "(", "start", ")", ",", "time_end", "=", "self", ".", "_format_time", ...
Add a request for a time range to the query. This modifies the query in-place, but returns `self` so that multiple queries can be chained together on one line. This replaces any existing temporal queries that have been set. Parameters ---------- start : datetime.dateti...
[ "Add", "a", "request", "for", "a", "time", "range", "to", "the", "query", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/http_util.py#L299-L322
train
Unidata/siphon
siphon/http_util.py
HTTPEndPoint.get_query
def get_query(self, query): """Make a GET request, including a query, to the endpoint. The path of the request is to the base URL assigned to the endpoint. Parameters ---------- query : DataQuery The query to pass when making the request Returns ---...
python
def get_query(self, query): """Make a GET request, including a query, to the endpoint. The path of the request is to the base URL assigned to the endpoint. Parameters ---------- query : DataQuery The query to pass when making the request Returns ---...
[ "def", "get_query", "(", "self", ",", "query", ")", ":", "url", "=", "self", ".", "_base", "[", ":", "-", "1", "]", "if", "self", ".", "_base", "[", "-", "1", "]", "==", "'/'", "else", "self", ".", "_base", "return", "self", ".", "get", "(", ...
Make a GET request, including a query, to the endpoint. The path of the request is to the base URL assigned to the endpoint. Parameters ---------- query : DataQuery The query to pass when making the request Returns ------- resp : requests.Response ...
[ "Make", "a", "GET", "request", "including", "a", "query", "to", "the", "endpoint", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/http_util.py#L381-L402
train
Unidata/siphon
siphon/http_util.py
HTTPEndPoint.get_path
def get_path(self, path, query=None): """Make a GET request, optionally including a query, to a relative path. The path of the request includes a path on top of the base URL assigned to the endpoint. Parameters ---------- path : str The path to request, rela...
python
def get_path(self, path, query=None): """Make a GET request, optionally including a query, to a relative path. The path of the request includes a path on top of the base URL assigned to the endpoint. Parameters ---------- path : str The path to request, rela...
[ "def", "get_path", "(", "self", ",", "path", ",", "query", "=", "None", ")", ":", "return", "self", ".", "get", "(", "self", ".", "url_path", "(", "path", ")", ",", "query", ")" ]
Make a GET request, optionally including a query, to a relative path. The path of the request includes a path on top of the base URL assigned to the endpoint. Parameters ---------- path : str The path to request, relative to the endpoint query : DataQuery, o...
[ "Make", "a", "GET", "request", "optionally", "including", "a", "query", "to", "a", "relative", "path", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/http_util.py#L426-L449
train
Unidata/siphon
siphon/http_util.py
HTTPEndPoint.get
def get(self, path, params=None): """Make a GET request, optionally including a parameters, to a path. The path of the request is the full URL. Parameters ---------- path : str The URL to request params : DataQuery, optional The query to pass whe...
python
def get(self, path, params=None): """Make a GET request, optionally including a parameters, to a path. The path of the request is the full URL. Parameters ---------- path : str The URL to request params : DataQuery, optional The query to pass whe...
[ "def", "get", "(", "self", ",", "path", ",", "params", "=", "None", ")", ":", "resp", "=", "self", ".", "_session", ".", "get", "(", "path", ",", "params", "=", "params", ")", "if", "resp", ".", "status_code", "!=", "200", ":", "if", "resp", ".",...
Make a GET request, optionally including a parameters, to a path. The path of the request is the full URL. Parameters ---------- path : str The URL to request params : DataQuery, optional The query to pass when making the request Returns ...
[ "Make", "a", "GET", "request", "optionally", "including", "a", "parameters", "to", "a", "path", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/http_util.py#L451-L488
train
Unidata/siphon
siphon/cdmr/dataset.py
Group.path
def path(self): """Return the full path to the Group, including any parent Groups.""" # If root, return '/' if self.dataset is self: return '' else: # Otherwise recurse return self.dataset.path + '/' + self.name
python
def path(self): """Return the full path to the Group, including any parent Groups.""" # If root, return '/' if self.dataset is self: return '' else: # Otherwise recurse return self.dataset.path + '/' + self.name
[ "def", "path", "(", "self", ")", ":", "# If root, return '/'", "if", "self", ".", "dataset", "is", "self", ":", "return", "''", "else", ":", "# Otherwise recurse", "return", "self", ".", "dataset", ".", "path", "+", "'/'", "+", "self", ".", "name" ]
Return the full path to the Group, including any parent Groups.
[ "Return", "the", "full", "path", "to", "the", "Group", "including", "any", "parent", "Groups", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/cdmr/dataset.py#L53-L59
train
Unidata/siphon
siphon/cdmr/dataset.py
Group.load_from_stream
def load_from_stream(self, group): """Load a Group from an NCStream object.""" self._unpack_attrs(group.atts) self.name = group.name for dim in group.dims: new_dim = Dimension(self, dim.name) self.dimensions[dim.name] = new_dim new_dim.load_from_strea...
python
def load_from_stream(self, group): """Load a Group from an NCStream object.""" self._unpack_attrs(group.atts) self.name = group.name for dim in group.dims: new_dim = Dimension(self, dim.name) self.dimensions[dim.name] = new_dim new_dim.load_from_strea...
[ "def", "load_from_stream", "(", "self", ",", "group", ")", ":", "self", ".", "_unpack_attrs", "(", "group", ".", "atts", ")", "self", ".", "name", "=", "group", ".", "name", "for", "dim", "in", "group", ".", "dims", ":", "new_dim", "=", "Dimension", ...
Load a Group from an NCStream object.
[ "Load", "a", "Group", "from", "an", "NCStream", "object", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/cdmr/dataset.py#L61-L89
train
Unidata/siphon
siphon/cdmr/dataset.py
Variable.load_from_stream
def load_from_stream(self, var): """Populate the Variable from an NCStream object.""" dims = [] for d in var.shape: dim = Dimension(None, d.name) dim.load_from_stream(d) dims.append(dim) self.dimensions = tuple(dim.name for dim in dims) self.s...
python
def load_from_stream(self, var): """Populate the Variable from an NCStream object.""" dims = [] for d in var.shape: dim = Dimension(None, d.name) dim.load_from_stream(d) dims.append(dim) self.dimensions = tuple(dim.name for dim in dims) self.s...
[ "def", "load_from_stream", "(", "self", ",", "var", ")", ":", "dims", "=", "[", "]", "for", "d", "in", "var", ".", "shape", ":", "dim", "=", "Dimension", "(", "None", ",", "d", ".", "name", ")", "dim", ".", "load_from_stream", "(", "d", ")", "dim...
Populate the Variable from an NCStream object.
[ "Populate", "the", "Variable", "from", "an", "NCStream", "object", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/cdmr/dataset.py#L288-L310
train
Unidata/siphon
siphon/cdmr/dataset.py
Dimension.load_from_stream
def load_from_stream(self, dim): """Load from an NCStream object.""" self.unlimited = dim.isUnlimited self.private = dim.isPrivate self.vlen = dim.isVlen if not self.vlen: self.size = dim.length
python
def load_from_stream(self, dim): """Load from an NCStream object.""" self.unlimited = dim.isUnlimited self.private = dim.isPrivate self.vlen = dim.isVlen if not self.vlen: self.size = dim.length
[ "def", "load_from_stream", "(", "self", ",", "dim", ")", ":", "self", ".", "unlimited", "=", "dim", ".", "isUnlimited", "self", ".", "private", "=", "dim", ".", "isPrivate", "self", ".", "vlen", "=", "dim", ".", "isVlen", "if", "not", "self", ".", "v...
Load from an NCStream object.
[ "Load", "from", "an", "NCStream", "object", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/cdmr/dataset.py#L349-L355
train
Unidata/siphon
siphon/cdmr/coveragedataset.py
CoverageDataset._read_header
def _read_header(self): """Get the needed header information to initialize dataset.""" self._header = self.cdmrf.fetch_header() self.load_from_stream(self._header)
python
def _read_header(self): """Get the needed header information to initialize dataset.""" self._header = self.cdmrf.fetch_header() self.load_from_stream(self._header)
[ "def", "_read_header", "(", "self", ")", ":", "self", ".", "_header", "=", "self", ".", "cdmrf", ".", "fetch_header", "(", ")", "self", ".", "load_from_stream", "(", "self", ".", "_header", ")" ]
Get the needed header information to initialize dataset.
[ "Get", "the", "needed", "header", "information", "to", "initialize", "dataset", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/cdmr/coveragedataset.py#L45-L48
train
Unidata/siphon
siphon/cdmr/coveragedataset.py
CoverageDataset.load_from_stream
def load_from_stream(self, header): """Populate the CoverageDataset from the protobuf information.""" self._unpack_attrs(header.atts) self.name = header.name self.lon_lat_domain = header.latlonRect self.proj_domain = header.projRect self.date_range = header.dateRange ...
python
def load_from_stream(self, header): """Populate the CoverageDataset from the protobuf information.""" self._unpack_attrs(header.atts) self.name = header.name self.lon_lat_domain = header.latlonRect self.proj_domain = header.projRect self.date_range = header.dateRange ...
[ "def", "load_from_stream", "(", "self", ",", "header", ")", ":", "self", ".", "_unpack_attrs", "(", "header", ".", "atts", ")", "self", ".", "name", "=", "header", ".", "name", "self", ".", "lon_lat_domain", "=", "header", ".", "latlonRect", "self", ".",...
Populate the CoverageDataset from the protobuf information.
[ "Populate", "the", "CoverageDataset", "from", "the", "protobuf", "information", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/cdmr/coveragedataset.py#L50-L69
train
Unidata/siphon
siphon/simplewebservice/iastate.py
IAStateUpperAir.request_data
def request_data(cls, time, site_id, **kwargs): """Retrieve upper air observations from Iowa State's archive for a single station. Parameters ---------- time : datetime The date and time of the desired observation. site_id : str The three letter ICAO ide...
python
def request_data(cls, time, site_id, **kwargs): """Retrieve upper air observations from Iowa State's archive for a single station. Parameters ---------- time : datetime The date and time of the desired observation. site_id : str The three letter ICAO ide...
[ "def", "request_data", "(", "cls", ",", "time", ",", "site_id", ",", "*", "*", "kwargs", ")", ":", "endpoint", "=", "cls", "(", ")", "df", "=", "endpoint", ".", "_get_data", "(", "time", ",", "site_id", ",", "None", ",", "*", "*", "kwargs", ")", ...
Retrieve upper air observations from Iowa State's archive for a single station. Parameters ---------- time : datetime The date and time of the desired observation. site_id : str The three letter ICAO identifier of the station for which data should be ...
[ "Retrieve", "upper", "air", "observations", "from", "Iowa", "State", "s", "archive", "for", "a", "single", "station", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/simplewebservice/iastate.py#L28-L50
train
Unidata/siphon
siphon/simplewebservice/iastate.py
IAStateUpperAir.request_all_data
def request_all_data(cls, time, pressure=None, **kwargs): """Retrieve upper air observations from Iowa State's archive for all stations. Parameters ---------- time : datetime The date and time of the desired observation. pressure : float, optional The ma...
python
def request_all_data(cls, time, pressure=None, **kwargs): """Retrieve upper air observations from Iowa State's archive for all stations. Parameters ---------- time : datetime The date and time of the desired observation. pressure : float, optional The ma...
[ "def", "request_all_data", "(", "cls", ",", "time", ",", "pressure", "=", "None", ",", "*", "*", "kwargs", ")", ":", "endpoint", "=", "cls", "(", ")", "df", "=", "endpoint", ".", "_get_data", "(", "time", ",", "None", ",", "pressure", ",", "*", "*"...
Retrieve upper air observations from Iowa State's archive for all stations. Parameters ---------- time : datetime The date and time of the desired observation. pressure : float, optional The mandatory pressure level at which to request data (in hPa). If none is ...
[ "Retrieve", "upper", "air", "observations", "from", "Iowa", "State", "s", "archive", "for", "all", "stations", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/simplewebservice/iastate.py#L53-L75
train
Unidata/siphon
siphon/simplewebservice/iastate.py
IAStateUpperAir._get_data
def _get_data(self, time, site_id, pressure=None): """Download data from Iowa State's upper air archive. Parameters ---------- time : datetime Date and time for which data should be downloaded site_id : str Site id for which data should be downloaded ...
python
def _get_data(self, time, site_id, pressure=None): """Download data from Iowa State's upper air archive. Parameters ---------- time : datetime Date and time for which data should be downloaded site_id : str Site id for which data should be downloaded ...
[ "def", "_get_data", "(", "self", ",", "time", ",", "site_id", ",", "pressure", "=", "None", ")", ":", "json_data", "=", "self", ".", "_get_data_raw", "(", "time", ",", "site_id", ",", "pressure", ")", "data", "=", "{", "}", "for", "profile", "in", "j...
Download data from Iowa State's upper air archive. Parameters ---------- time : datetime Date and time for which data should be downloaded site_id : str Site id for which data should be downloaded pressure : float, optional Mandatory pressure ...
[ "Download", "data", "from", "Iowa", "State", "s", "upper", "air", "archive", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/simplewebservice/iastate.py#L77-L139
train
Unidata/siphon
siphon/simplewebservice/iastate.py
IAStateUpperAir._get_data_raw
def _get_data_raw(self, time, site_id, pressure=None): r"""Download data from the Iowa State's upper air archive. Parameters ---------- time : datetime Date and time for which data should be downloaded site_id : str Site id for which data should be downlo...
python
def _get_data_raw(self, time, site_id, pressure=None): r"""Download data from the Iowa State's upper air archive. Parameters ---------- time : datetime Date and time for which data should be downloaded site_id : str Site id for which data should be downlo...
[ "def", "_get_data_raw", "(", "self", ",", "time", ",", "site_id", ",", "pressure", "=", "None", ")", ":", "query", "=", "{", "'ts'", ":", "time", ".", "strftime", "(", "'%Y%m%d%H00'", ")", "}", "if", "site_id", "is", "not", "None", ":", "query", "[",...
r"""Download data from the Iowa State's upper air archive. Parameters ---------- time : datetime Date and time for which data should be downloaded site_id : str Site id for which data should be downloaded pressure : float, optional Mandatory p...
[ "r", "Download", "data", "from", "the", "Iowa", "State", "s", "upper", "air", "archive", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/simplewebservice/iastate.py#L141-L178
train
Unidata/siphon
siphon/radarserver.py
parse_station_table
def parse_station_table(root): """Parse station list XML file.""" stations = [parse_xml_station(elem) for elem in root.findall('station')] return {st.id: st for st in stations}
python
def parse_station_table(root): """Parse station list XML file.""" stations = [parse_xml_station(elem) for elem in root.findall('station')] return {st.id: st for st in stations}
[ "def", "parse_station_table", "(", "root", ")", ":", "stations", "=", "[", "parse_xml_station", "(", "elem", ")", "for", "elem", "in", "root", ".", "findall", "(", "'station'", ")", "]", "return", "{", "st", ".", "id", ":", "st", "for", "st", "in", "...
Parse station list XML file.
[ "Parse", "station", "list", "XML", "file", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/radarserver.py#L217-L220
train
Unidata/siphon
siphon/radarserver.py
parse_xml_station
def parse_xml_station(elem): """Create a :class:`Station` instance from an XML tag.""" stid = elem.attrib['id'] name = elem.find('name').text lat = float(elem.find('latitude').text) lon = float(elem.find('longitude').text) elev = float(elem.find('elevation').text) return Station(id=stid, ele...
python
def parse_xml_station(elem): """Create a :class:`Station` instance from an XML tag.""" stid = elem.attrib['id'] name = elem.find('name').text lat = float(elem.find('latitude').text) lon = float(elem.find('longitude').text) elev = float(elem.find('elevation').text) return Station(id=stid, ele...
[ "def", "parse_xml_station", "(", "elem", ")", ":", "stid", "=", "elem", ".", "attrib", "[", "'id'", "]", "name", "=", "elem", ".", "find", "(", "'name'", ")", ".", "text", "lat", "=", "float", "(", "elem", ".", "find", "(", "'latitude'", ")", ".", ...
Create a :class:`Station` instance from an XML tag.
[ "Create", "a", ":", "class", ":", "Station", "instance", "from", "an", "XML", "tag", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/radarserver.py#L223-L230
train
Unidata/siphon
siphon/radarserver.py
RadarQuery.stations
def stations(self, *stns): """Specify one or more stations for the query. This modifies the query in-place, but returns `self` so that multiple queries can be chained together on one line. This replaces any existing spatial queries that have been set. Parameters ------...
python
def stations(self, *stns): """Specify one or more stations for the query. This modifies the query in-place, but returns `self` so that multiple queries can be chained together on one line. This replaces any existing spatial queries that have been set. Parameters ------...
[ "def", "stations", "(", "self", ",", "*", "stns", ")", ":", "self", ".", "_set_query", "(", "self", ".", "spatial_query", ",", "stn", "=", "stns", ")", "return", "self" ]
Specify one or more stations for the query. This modifies the query in-place, but returns `self` so that multiple queries can be chained together on one line. This replaces any existing spatial queries that have been set. Parameters ---------- stns : one or more string...
[ "Specify", "one", "or", "more", "stations", "for", "the", "query", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/radarserver.py#L23-L43
train
Unidata/siphon
siphon/radarserver.py
RadarServer.validate_query
def validate_query(self, query): """Validate a query. Determines whether `query` is well-formed. This includes checking for all required parameters, as well as checking parameters for valid values. Parameters ---------- query : RadarQuery The query to valida...
python
def validate_query(self, query): """Validate a query. Determines whether `query` is well-formed. This includes checking for all required parameters, as well as checking parameters for valid values. Parameters ---------- query : RadarQuery The query to valida...
[ "def", "validate_query", "(", "self", ",", "query", ")", ":", "valid", "=", "True", "# Make sure all stations are in the table", "if", "'stn'", "in", "query", ".", "spatial_query", ":", "valid", "=", "valid", "and", "all", "(", "stid", "in", "self", ".", "st...
Validate a query. Determines whether `query` is well-formed. This includes checking for all required parameters, as well as checking parameters for valid values. Parameters ---------- query : RadarQuery The query to validate Returns ------- ...
[ "Validate", "a", "query", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/radarserver.py#L101-L127
train
Unidata/siphon
siphon/radarserver.py
RadarServer.get_catalog
def get_catalog(self, query): """Fetch a parsed THREDDS catalog from the radar server. Requests a catalog of radar data files data from the radar server given the parameters in `query` and returns a :class:`~siphon.catalog.TDSCatalog` instance. Parameters ---------- que...
python
def get_catalog(self, query): """Fetch a parsed THREDDS catalog from the radar server. Requests a catalog of radar data files data from the radar server given the parameters in `query` and returns a :class:`~siphon.catalog.TDSCatalog` instance. Parameters ---------- que...
[ "def", "get_catalog", "(", "self", ",", "query", ")", ":", "# TODO: Refactor TDSCatalog so we don't need two requests, or to do URL munging", "try", ":", "url", "=", "self", ".", "_base", "[", ":", "-", "1", "]", "if", "self", ".", "_base", "[", "-", "1", "]",...
Fetch a parsed THREDDS catalog from the radar server. Requests a catalog of radar data files data from the radar server given the parameters in `query` and returns a :class:`~siphon.catalog.TDSCatalog` instance. Parameters ---------- query : RadarQuery The parameter...
[ "Fetch", "a", "parsed", "THREDDS", "catalog", "from", "the", "radar", "server", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/radarserver.py#L129-L161
train
Unidata/siphon
siphon/simplewebservice/acis.py
acis_request
def acis_request(method, params): """Request data from the ACIS Web Services API. Makes a request from the ACIS Web Services API for data based on a given method (StnMeta,StnData,MultiStnData,GridData,General) and parameters string. Information about the parameters can be obtained at: http://www.rc...
python
def acis_request(method, params): """Request data from the ACIS Web Services API. Makes a request from the ACIS Web Services API for data based on a given method (StnMeta,StnData,MultiStnData,GridData,General) and parameters string. Information about the parameters can be obtained at: http://www.rc...
[ "def", "acis_request", "(", "method", ",", "params", ")", ":", "base_url", "=", "'http://data.rcc-acis.org/'", "# ACIS Web API URL", "timeout", "=", "300", "if", "method", "==", "'MultiStnData'", "else", "60", "try", ":", "response", "=", "session_manager", ".", ...
Request data from the ACIS Web Services API. Makes a request from the ACIS Web Services API for data based on a given method (StnMeta,StnData,MultiStnData,GridData,General) and parameters string. Information about the parameters can be obtained at: http://www.rcc-acis.org/docs_webservices.html If ...
[ "Request", "data", "from", "the", "ACIS", "Web", "Services", "API", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/simplewebservice/acis.py#L11-L63
train
Unidata/siphon
siphon/ncss.py
parse_xml
def parse_xml(data, handle_units): """Parse XML data returned by NCSS.""" root = ET.fromstring(data) return squish(parse_xml_dataset(root, handle_units))
python
def parse_xml(data, handle_units): """Parse XML data returned by NCSS.""" root = ET.fromstring(data) return squish(parse_xml_dataset(root, handle_units))
[ "def", "parse_xml", "(", "data", ",", "handle_units", ")", ":", "root", "=", "ET", ".", "fromstring", "(", "data", ")", "return", "squish", "(", "parse_xml_dataset", "(", "root", ",", "handle_units", ")", ")" ]
Parse XML data returned by NCSS.
[ "Parse", "XML", "data", "returned", "by", "NCSS", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/ncss.py#L315-L318
train
Unidata/siphon
siphon/ncss.py
parse_xml_point
def parse_xml_point(elem): """Parse an XML point tag.""" point = {} units = {} for data in elem.findall('data'): name = data.get('name') unit = data.get('units') point[name] = float(data.text) if name != 'date' else parse_iso_date(data.text) if unit: units[nam...
python
def parse_xml_point(elem): """Parse an XML point tag.""" point = {} units = {} for data in elem.findall('data'): name = data.get('name') unit = data.get('units') point[name] = float(data.text) if name != 'date' else parse_iso_date(data.text) if unit: units[nam...
[ "def", "parse_xml_point", "(", "elem", ")", ":", "point", "=", "{", "}", "units", "=", "{", "}", "for", "data", "in", "elem", ".", "findall", "(", "'data'", ")", ":", "name", "=", "data", ".", "get", "(", "'name'", ")", "unit", "=", "data", ".", ...
Parse an XML point tag.
[ "Parse", "an", "XML", "point", "tag", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/ncss.py#L321-L331
train
Unidata/siphon
siphon/ncss.py
combine_xml_points
def combine_xml_points(l, units, handle_units): """Combine multiple Point tags into an array.""" ret = {} for item in l: for key, value in item.items(): ret.setdefault(key, []).append(value) for key, value in ret.items(): if key != 'date': ret[key] = handle_units...
python
def combine_xml_points(l, units, handle_units): """Combine multiple Point tags into an array.""" ret = {} for item in l: for key, value in item.items(): ret.setdefault(key, []).append(value) for key, value in ret.items(): if key != 'date': ret[key] = handle_units...
[ "def", "combine_xml_points", "(", "l", ",", "units", ",", "handle_units", ")", ":", "ret", "=", "{", "}", "for", "item", "in", "l", ":", "for", "key", ",", "value", "in", "item", ".", "items", "(", ")", ":", "ret", ".", "setdefault", "(", "key", ...
Combine multiple Point tags into an array.
[ "Combine", "multiple", "Point", "tags", "into", "an", "array", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/ncss.py#L334-L345
train
Unidata/siphon
siphon/ncss.py
parse_xml_dataset
def parse_xml_dataset(elem, handle_units): """Create a netCDF-like dataset from XML data.""" points, units = zip(*[parse_xml_point(p) for p in elem.findall('point')]) # Group points by the contents of each point datasets = {} for p in points: datasets.setdefault(tuple(p), []).append(p) ...
python
def parse_xml_dataset(elem, handle_units): """Create a netCDF-like dataset from XML data.""" points, units = zip(*[parse_xml_point(p) for p in elem.findall('point')]) # Group points by the contents of each point datasets = {} for p in points: datasets.setdefault(tuple(p), []).append(p) ...
[ "def", "parse_xml_dataset", "(", "elem", ",", "handle_units", ")", ":", "points", ",", "units", "=", "zip", "(", "*", "[", "parse_xml_point", "(", "p", ")", "for", "p", "in", "elem", ".", "findall", "(", "'point'", ")", "]", ")", "# Group points by the c...
Create a netCDF-like dataset from XML data.
[ "Create", "a", "netCDF", "-", "like", "dataset", "from", "XML", "data", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/ncss.py#L348-L357
train
Unidata/siphon
siphon/ncss.py
parse_csv_response
def parse_csv_response(data, unit_handler): """Handle CSV-formatted HTTP responses.""" return squish([parse_csv_dataset(d, unit_handler) for d in data.split(b'\n\n')])
python
def parse_csv_response(data, unit_handler): """Handle CSV-formatted HTTP responses.""" return squish([parse_csv_dataset(d, unit_handler) for d in data.split(b'\n\n')])
[ "def", "parse_csv_response", "(", "data", ",", "unit_handler", ")", ":", "return", "squish", "(", "[", "parse_csv_dataset", "(", "d", ",", "unit_handler", ")", "for", "d", "in", "data", ".", "split", "(", "b'\\n\\n'", ")", "]", ")" ]
Handle CSV-formatted HTTP responses.
[ "Handle", "CSV", "-", "formatted", "HTTP", "responses", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/ncss.py#L403-L405
train
Unidata/siphon
siphon/ncss.py
parse_csv_header
def parse_csv_header(line): """Parse the CSV header returned by TDS.""" units = {} names = [] for var in line.split(','): start = var.find('[') if start < 0: names.append(str(var)) continue else: names.append(str(var[:start])) end = var...
python
def parse_csv_header(line): """Parse the CSV header returned by TDS.""" units = {} names = [] for var in line.split(','): start = var.find('[') if start < 0: names.append(str(var)) continue else: names.append(str(var[:start])) end = var...
[ "def", "parse_csv_header", "(", "line", ")", ":", "units", "=", "{", "}", "names", "=", "[", "]", "for", "var", "in", "line", ".", "split", "(", "','", ")", ":", "start", "=", "var", ".", "find", "(", "'['", ")", "if", "start", "<", "0", ":", ...
Parse the CSV header returned by TDS.
[ "Parse", "the", "CSV", "header", "returned", "by", "TDS", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/ncss.py#L408-L425
train
Unidata/siphon
siphon/ncss.py
parse_csv_dataset
def parse_csv_dataset(data, handle_units): """Parse CSV data into a netCDF-like dataset.""" fobj = BytesIO(data) names, units = parse_csv_header(fobj.readline().decode('utf-8')) arrs = np.genfromtxt(fobj, dtype=None, names=names, delimiter=',', unpack=True, converters={'date': l...
python
def parse_csv_dataset(data, handle_units): """Parse CSV data into a netCDF-like dataset.""" fobj = BytesIO(data) names, units = parse_csv_header(fobj.readline().decode('utf-8')) arrs = np.genfromtxt(fobj, dtype=None, names=names, delimiter=',', unpack=True, converters={'date': l...
[ "def", "parse_csv_dataset", "(", "data", ",", "handle_units", ")", ":", "fobj", "=", "BytesIO", "(", "data", ")", "names", ",", "units", "=", "parse_csv_header", "(", "fobj", ".", "readline", "(", ")", ".", "decode", "(", "'utf-8'", ")", ")", "arrs", "...
Parse CSV data into a netCDF-like dataset.
[ "Parse", "CSV", "data", "into", "a", "netCDF", "-", "like", "dataset", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/ncss.py#L428-L440
train
Unidata/siphon
siphon/ncss.py
NCSS.validate_query
def validate_query(self, query): """Validate a query. Determines whether `query` is well-formed. This includes checking for all required parameters, as well as checking parameters for valid values. Parameters ---------- query : NCSSQuery The query to validat...
python
def validate_query(self, query): """Validate a query. Determines whether `query` is well-formed. This includes checking for all required parameters, as well as checking parameters for valid values. Parameters ---------- query : NCSSQuery The query to validat...
[ "def", "validate_query", "(", "self", ",", "query", ")", ":", "# Make sure all variables are in the dataset", "return", "bool", "(", "query", ".", "var", ")", "and", "all", "(", "var", "in", "self", ".", "variables", "for", "var", "in", "query", ".", "var", ...
Validate a query. Determines whether `query` is well-formed. This includes checking for all required parameters, as well as checking parameters for valid values. Parameters ---------- query : NCSSQuery The query to validate Returns ------- v...
[ "Validate", "a", "query", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/ncss.py#L73-L91
train
Unidata/siphon
siphon/ncss.py
NCSS.get_data
def get_data(self, query): """Fetch parsed data from a THREDDS server using NCSS. Requests data from the NCSS endpoint given the parameters in `query` and handles parsing of the returned content based on the mimetype. Parameters ---------- query : NCSSQuery ...
python
def get_data(self, query): """Fetch parsed data from a THREDDS server using NCSS. Requests data from the NCSS endpoint given the parameters in `query` and handles parsing of the returned content based on the mimetype. Parameters ---------- query : NCSSQuery ...
[ "def", "get_data", "(", "self", ",", "query", ")", ":", "resp", "=", "self", ".", "get_query", "(", "query", ")", "return", "response_handlers", "(", "resp", ",", "self", ".", "unit_handler", ")" ]
Fetch parsed data from a THREDDS server using NCSS. Requests data from the NCSS endpoint given the parameters in `query` and handles parsing of the returned content based on the mimetype. Parameters ---------- query : NCSSQuery The parameters to send to the NCSS end...
[ "Fetch", "parsed", "data", "from", "a", "THREDDS", "server", "using", "NCSS", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/ncss.py#L93-L115
train
Unidata/siphon
siphon/ncss.py
NCSSQuery.projection_box
def projection_box(self, min_x, min_y, max_x, max_y): """Add a bounding box in projected (native) coordinates to the query. This adds a request for a spatial bounding box, bounded by (`min_x`, `max_x`) for x direction and (`min_y`, `max_y`) for the y direction. This modifies the query i...
python
def projection_box(self, min_x, min_y, max_x, max_y): """Add a bounding box in projected (native) coordinates to the query. This adds a request for a spatial bounding box, bounded by (`min_x`, `max_x`) for x direction and (`min_y`, `max_y`) for the y direction. This modifies the query i...
[ "def", "projection_box", "(", "self", ",", "min_x", ",", "min_y", ",", "max_x", ",", "max_y", ")", ":", "self", ".", "_set_query", "(", "self", ".", "spatial_query", ",", "minx", "=", "min_x", ",", "miny", "=", "min_y", ",", "maxx", "=", "max_x", ","...
Add a bounding box in projected (native) coordinates to the query. This adds a request for a spatial bounding box, bounded by (`min_x`, `max_x`) for x direction and (`min_y`, `max_y`) for the y direction. This modifies the query in-place, but returns ``self`` so that multiple queries can be cha...
[ "Add", "a", "bounding", "box", "in", "projected", "(", "native", ")", "coordinates", "to", "the", "query", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/ncss.py#L148-L177
train
Unidata/siphon
siphon/ncss.py
NCSSQuery.strides
def strides(self, time=None, spatial=None): """Set time and/or spatial (horizontal) strides. This is only used on grid requests. Used to skip points in the returned data. This modifies the query in-place, but returns `self` so that multiple queries can be chained together on one line. ...
python
def strides(self, time=None, spatial=None): """Set time and/or spatial (horizontal) strides. This is only used on grid requests. Used to skip points in the returned data. This modifies the query in-place, but returns `self` so that multiple queries can be chained together on one line. ...
[ "def", "strides", "(", "self", ",", "time", "=", "None", ",", "spatial", "=", "None", ")", ":", "if", "time", ":", "self", ".", "add_query_parameter", "(", "timeStride", "=", "time", ")", "if", "spatial", ":", "self", ".", "add_query_parameter", "(", "...
Set time and/or spatial (horizontal) strides. This is only used on grid requests. Used to skip points in the returned data. This modifies the query in-place, but returns `self` so that multiple queries can be chained together on one line. Parameters ---------- time : in...
[ "Set", "time", "and", "/", "or", "spatial", "(", "horizontal", ")", "strides", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/ncss.py#L218-L242
train
Unidata/siphon
siphon/ncss.py
ResponseRegistry.register
def register(self, mimetype): """Register a function to handle a particular mimetype.""" def dec(func): self._reg[mimetype] = func return func return dec
python
def register(self, mimetype): """Register a function to handle a particular mimetype.""" def dec(func): self._reg[mimetype] = func return func return dec
[ "def", "register", "(", "self", ",", "mimetype", ")", ":", "def", "dec", "(", "func", ")", ":", "self", ".", "_reg", "[", "mimetype", "]", "=", "func", "return", "func", "return", "dec" ]
Register a function to handle a particular mimetype.
[ "Register", "a", "function", "to", "handle", "a", "particular", "mimetype", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/ncss.py#L279-L284
train
Unidata/siphon
siphon/ncss_dataset.py
_Types.handle_typed_values
def handle_typed_values(val, type_name, value_type): """Translate typed values into the appropriate python object. Takes an element name, value, and type and returns a list with the string value(s) properly converted to a python type. TypedValues are handled in ucar.ma2.DataType in net...
python
def handle_typed_values(val, type_name, value_type): """Translate typed values into the appropriate python object. Takes an element name, value, and type and returns a list with the string value(s) properly converted to a python type. TypedValues are handled in ucar.ma2.DataType in net...
[ "def", "handle_typed_values", "(", "val", ",", "type_name", ",", "value_type", ")", ":", "if", "value_type", "in", "[", "'byte'", ",", "'short'", ",", "'int'", ",", "'long'", "]", ":", "try", ":", "val", "=", "[", "int", "(", "v", ")", "for", "v", ...
Translate typed values into the appropriate python object. Takes an element name, value, and type and returns a list with the string value(s) properly converted to a python type. TypedValues are handled in ucar.ma2.DataType in netcdfJava in the DataType enum. Possibilities are: ...
[ "Translate", "typed", "values", "into", "the", "appropriate", "python", "object", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/ncss_dataset.py#L26-L114
train
Unidata/siphon
siphon/simplewebservice/wyoming.py
WyomingUpperAir._get_data
def _get_data(self, time, site_id): r"""Download and parse upper air observations from an online archive. Parameters ---------- time : datetime The date and time of the desired observation. site_id : str The three letter ICAO identifier of the station fo...
python
def _get_data(self, time, site_id): r"""Download and parse upper air observations from an online archive. Parameters ---------- time : datetime The date and time of the desired observation. site_id : str The three letter ICAO identifier of the station fo...
[ "def", "_get_data", "(", "self", ",", "time", ",", "site_id", ")", ":", "raw_data", "=", "self", ".", "_get_data_raw", "(", "time", ",", "site_id", ")", "soup", "=", "BeautifulSoup", "(", "raw_data", ",", "'html.parser'", ")", "tabular_data", "=", "StringI...
r"""Download and parse upper air observations from an online archive. Parameters ---------- time : datetime The date and time of the desired observation. site_id : str The three letter ICAO identifier of the station for which data should be downloade...
[ "r", "Download", "and", "parse", "upper", "air", "observations", "from", "an", "online", "archive", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/simplewebservice/wyoming.py#L52-L119
train
Unidata/siphon
siphon/simplewebservice/wyoming.py
WyomingUpperAir._get_data_raw
def _get_data_raw(self, time, site_id): """Download data from the University of Wyoming's upper air archive. Parameters ---------- time : datetime Date and time for which data should be downloaded site_id : str Site id for which data should be downloaded ...
python
def _get_data_raw(self, time, site_id): """Download data from the University of Wyoming's upper air archive. Parameters ---------- time : datetime Date and time for which data should be downloaded site_id : str Site id for which data should be downloaded ...
[ "def", "_get_data_raw", "(", "self", ",", "time", ",", "site_id", ")", ":", "path", "=", "(", "'?region=naconf&TYPE=TEXT%3ALIST'", "'&YEAR={time:%Y}&MONTH={time:%m}&FROM={time:%d%H}&TO={time:%d%H}'", "'&STNM={stid}'", ")", ".", "format", "(", "time", "=", "time", ",", ...
Download data from the University of Wyoming's upper air archive. Parameters ---------- time : datetime Date and time for which data should be downloaded site_id : str Site id for which data should be downloaded Returns ------- text of th...
[ "Download", "data", "from", "the", "University", "of", "Wyoming", "s", "upper", "air", "archive", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/simplewebservice/wyoming.py#L121-L147
train
Unidata/siphon
siphon/cdmr/ncstream.py
read_ncstream_data
def read_ncstream_data(fobj): """Handle reading an NcStream v1 data block from a file-like object.""" data = read_proto_object(fobj, stream.Data) if data.dataType in (stream.STRING, stream.OPAQUE) or data.vdata: log.debug('Reading string/opaque/vlen') num_obj = read_var_int(fobj) log...
python
def read_ncstream_data(fobj): """Handle reading an NcStream v1 data block from a file-like object.""" data = read_proto_object(fobj, stream.Data) if data.dataType in (stream.STRING, stream.OPAQUE) or data.vdata: log.debug('Reading string/opaque/vlen') num_obj = read_var_int(fobj) log...
[ "def", "read_ncstream_data", "(", "fobj", ")", ":", "data", "=", "read_proto_object", "(", "fobj", ",", "stream", ".", "Data", ")", "if", "data", ".", "dataType", "in", "(", "stream", ".", "STRING", ",", "stream", ".", "OPAQUE", ")", "or", "data", ".",...
Handle reading an NcStream v1 data block from a file-like object.
[ "Handle", "reading", "an", "NcStream", "v1", "data", "block", "from", "a", "file", "-", "like", "object", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/cdmr/ncstream.py#L35-L91
train
Unidata/siphon
siphon/cdmr/ncstream.py
read_ncstream_err
def read_ncstream_err(fobj): """Handle reading an NcStream error from a file-like object and raise as error.""" err = read_proto_object(fobj, stream.Error) raise RuntimeError(err.message)
python
def read_ncstream_err(fobj): """Handle reading an NcStream error from a file-like object and raise as error.""" err = read_proto_object(fobj, stream.Error) raise RuntimeError(err.message)
[ "def", "read_ncstream_err", "(", "fobj", ")", ":", "err", "=", "read_proto_object", "(", "fobj", ",", "stream", ".", "Error", ")", "raise", "RuntimeError", "(", "err", ".", "message", ")" ]
Handle reading an NcStream error from a file-like object and raise as error.
[ "Handle", "reading", "an", "NcStream", "error", "from", "a", "file", "-", "like", "object", "and", "raise", "as", "error", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/cdmr/ncstream.py#L100-L103
train
Unidata/siphon
siphon/cdmr/ncstream.py
read_messages
def read_messages(fobj, magic_table): """Read messages from a file-like object until stream is exhausted.""" messages = [] while True: magic = read_magic(fobj) if not magic: break func = magic_table.get(magic) if func is not None: messages.append(fun...
python
def read_messages(fobj, magic_table): """Read messages from a file-like object until stream is exhausted.""" messages = [] while True: magic = read_magic(fobj) if not magic: break func = magic_table.get(magic) if func is not None: messages.append(fun...
[ "def", "read_messages", "(", "fobj", ",", "magic_table", ")", ":", "messages", "=", "[", "]", "while", "True", ":", "magic", "=", "read_magic", "(", "fobj", ")", "if", "not", "magic", ":", "break", "func", "=", "magic_table", ".", "get", "(", "magic", ...
Read messages from a file-like object until stream is exhausted.
[ "Read", "messages", "from", "a", "file", "-", "like", "object", "until", "stream", "is", "exhausted", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/cdmr/ncstream.py#L134-L150
train
Unidata/siphon
siphon/cdmr/ncstream.py
read_proto_object
def read_proto_object(fobj, klass): """Read a block of data and parse using the given protobuf object.""" log.debug('%s chunk', klass.__name__) obj = klass() obj.ParseFromString(read_block(fobj)) log.debug('Header: %s', str(obj)) return obj
python
def read_proto_object(fobj, klass): """Read a block of data and parse using the given protobuf object.""" log.debug('%s chunk', klass.__name__) obj = klass() obj.ParseFromString(read_block(fobj)) log.debug('Header: %s', str(obj)) return obj
[ "def", "read_proto_object", "(", "fobj", ",", "klass", ")", ":", "log", ".", "debug", "(", "'%s chunk'", ",", "klass", ".", "__name__", ")", "obj", "=", "klass", "(", ")", "obj", ".", "ParseFromString", "(", "read_block", "(", "fobj", ")", ")", "log", ...
Read a block of data and parse using the given protobuf object.
[ "Read", "a", "block", "of", "data", "and", "parse", "using", "the", "given", "protobuf", "object", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/cdmr/ncstream.py#L153-L159
train
Unidata/siphon
siphon/cdmr/ncstream.py
read_block
def read_block(fobj): """Read a block. Reads a block from a file object by first reading the number of bytes to read, which must be encoded as a variable-byte length integer. Parameters ---------- fobj : file-like object The file to read from. Returns ------- bytes ...
python
def read_block(fobj): """Read a block. Reads a block from a file object by first reading the number of bytes to read, which must be encoded as a variable-byte length integer. Parameters ---------- fobj : file-like object The file to read from. Returns ------- bytes ...
[ "def", "read_block", "(", "fobj", ")", ":", "num", "=", "read_var_int", "(", "fobj", ")", "log", ".", "debug", "(", "'Next block: %d bytes'", ",", "num", ")", "return", "fobj", ".", "read", "(", "num", ")" ]
Read a block. Reads a block from a file object by first reading the number of bytes to read, which must be encoded as a variable-byte length integer. Parameters ---------- fobj : file-like object The file to read from. Returns ------- bytes block of bytes read
[ "Read", "a", "block", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/cdmr/ncstream.py#L179-L198
train
Unidata/siphon
siphon/cdmr/ncstream.py
process_vlen
def process_vlen(data_header, array): """Process vlen coming back from NCStream v2. This takes the array of values and slices into an object array, with entries containing the appropriate pieces of the original array. Sizes are controlled by the passed in `data_header`. Parameters ---------- ...
python
def process_vlen(data_header, array): """Process vlen coming back from NCStream v2. This takes the array of values and slices into an object array, with entries containing the appropriate pieces of the original array. Sizes are controlled by the passed in `data_header`. Parameters ---------- ...
[ "def", "process_vlen", "(", "data_header", ",", "array", ")", ":", "source", "=", "iter", "(", "array", ")", "return", "np", ".", "array", "(", "[", "np", ".", "fromiter", "(", "itertools", ".", "islice", "(", "source", ",", "size", ")", ",", "dtype"...
Process vlen coming back from NCStream v2. This takes the array of values and slices into an object array, with entries containing the appropriate pieces of the original array. Sizes are controlled by the passed in `data_header`. Parameters ---------- data_header : Header array : :class:`n...
[ "Process", "vlen", "coming", "back", "from", "NCStream", "v2", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/cdmr/ncstream.py#L201-L221
train
Unidata/siphon
siphon/cdmr/ncstream.py
datacol_to_array
def datacol_to_array(datacol): """Convert DataCol from NCStream v2 into an array with appropriate type. Depending on the data type specified, this extracts data from the appropriate members and packs into a :class:`numpy.ndarray`, recursing as necessary for compound data types. Parameters --------...
python
def datacol_to_array(datacol): """Convert DataCol from NCStream v2 into an array with appropriate type. Depending on the data type specified, this extracts data from the appropriate members and packs into a :class:`numpy.ndarray`, recursing as necessary for compound data types. Parameters --------...
[ "def", "datacol_to_array", "(", "datacol", ")", ":", "if", "datacol", ".", "dataType", "==", "stream", ".", "STRING", ":", "arr", "=", "np", ".", "array", "(", "datacol", ".", "stringdata", ",", "dtype", "=", "np", ".", "object", ")", "elif", "datacol"...
Convert DataCol from NCStream v2 into an array with appropriate type. Depending on the data type specified, this extracts data from the appropriate members and packs into a :class:`numpy.ndarray`, recursing as necessary for compound data types. Parameters ---------- datacol : DataCol Returns ...
[ "Convert", "DataCol", "from", "NCStream", "v2", "into", "an", "array", "with", "appropriate", "type", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/cdmr/ncstream.py#L224-L278
train
Unidata/siphon
siphon/cdmr/ncstream.py
reshape_array
def reshape_array(data_header, array): """Extract the appropriate array shape from the header. Can handle taking a data header and either bytes containing data or a StructureData instance, which will have binary data as well as some additional information. Parameters ---------- array : :class:...
python
def reshape_array(data_header, array): """Extract the appropriate array shape from the header. Can handle taking a data header and either bytes containing data or a StructureData instance, which will have binary data as well as some additional information. Parameters ---------- array : :class:...
[ "def", "reshape_array", "(", "data_header", ",", "array", ")", ":", "shape", "=", "tuple", "(", "r", ".", "size", "for", "r", "in", "data_header", ".", "section", ".", "range", ")", "if", "shape", ":", "return", "array", ".", "reshape", "(", "*", "sh...
Extract the appropriate array shape from the header. Can handle taking a data header and either bytes containing data or a StructureData instance, which will have binary data as well as some additional information. Parameters ---------- array : :class:`numpy.ndarray` data_header : Data
[ "Extract", "the", "appropriate", "array", "shape", "from", "the", "header", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/cdmr/ncstream.py#L281-L297
train
Unidata/siphon
siphon/cdmr/ncstream.py
data_type_to_numpy
def data_type_to_numpy(datatype, unsigned=False): """Convert an ncstream datatype to a numpy one.""" basic_type = _dtypeLookup[datatype] if datatype in (stream.STRING, stream.OPAQUE): return np.dtype(basic_type) if unsigned: basic_type = basic_type.replace('i', 'u') return np.dtype...
python
def data_type_to_numpy(datatype, unsigned=False): """Convert an ncstream datatype to a numpy one.""" basic_type = _dtypeLookup[datatype] if datatype in (stream.STRING, stream.OPAQUE): return np.dtype(basic_type) if unsigned: basic_type = basic_type.replace('i', 'u') return np.dtype...
[ "def", "data_type_to_numpy", "(", "datatype", ",", "unsigned", "=", "False", ")", ":", "basic_type", "=", "_dtypeLookup", "[", "datatype", "]", "if", "datatype", "in", "(", "stream", ".", "STRING", ",", "stream", ".", "OPAQUE", ")", ":", "return", "np", ...
Convert an ncstream datatype to a numpy one.
[ "Convert", "an", "ncstream", "datatype", "to", "a", "numpy", "one", "." ]
53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/cdmr/ncstream.py#L310-L319
train