partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | make_long_description | click_ is a framework to simplify writing composable commands for
command-line tools. This package extends the click_ functionality
by adding support for commands that use configuration files.
.. _click: https://click.pocoo.org/
EXAMPLE:
A configuration file, like:
.. code-block:: INI
... | setup.py | def make_long_description(marker=None, intro=None):
"""
click_ is a framework to simplify writing composable commands for
command-line tools. This package extends the click_ functionality
by adding support for commands that use configuration files.
.. _click: https://click.pocoo.org/
EXAMPLE:
... | def make_long_description(marker=None, intro=None):
"""
click_ is a framework to simplify writing composable commands for
command-line tools. This package extends the click_ functionality
by adding support for commands that use configuration files.
.. _click: https://click.pocoo.org/
EXAMPLE:
... | [
"click_",
"is",
"a",
"framework",
"to",
"simplify",
"writing",
"composable",
"commands",
"for",
"command",
"-",
"line",
"tools",
".",
"This",
"package",
"extends",
"the",
"click_",
"functionality",
"by",
"adding",
"support",
"for",
"commands",
"that",
"use",
"... | click-contrib/click-configfile | python | https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/setup.py#L35-L83 | [
"def",
"make_long_description",
"(",
"marker",
"=",
"None",
",",
"intro",
"=",
"None",
")",
":",
"if",
"intro",
"is",
"None",
":",
"intro",
"=",
"inspect",
".",
"getdoc",
"(",
"make_long_description",
")",
"with",
"open",
"(",
"\"README.rst\"",
",",
"\"r\"... | a616204cb9944125fd5051556f27a7ccef611e22 |
train | PubSubClient.pubsub_pop_message | Pops a message for a subscribed client.
Args:
deadline (int): max number of seconds to wait (None => no timeout)
Returns:
Future with the popped message as result (or None if timeout
or ConnectionError object in case of connection errors
or Clien... | tornadis/pubsub.py | def pubsub_pop_message(self, deadline=None):
"""Pops a message for a subscribed client.
Args:
deadline (int): max number of seconds to wait (None => no timeout)
Returns:
Future with the popped message as result (or None if timeout
or ConnectionError obje... | def pubsub_pop_message(self, deadline=None):
"""Pops a message for a subscribed client.
Args:
deadline (int): max number of seconds to wait (None => no timeout)
Returns:
Future with the popped message as result (or None if timeout
or ConnectionError obje... | [
"Pops",
"a",
"message",
"for",
"a",
"subscribed",
"client",
"."
] | thefab/tornadis | python | https://github.com/thefab/tornadis/blob/f9dc883e46eb5971b62eab38346319757e5f900f/tornadis/pubsub.py#L140-L170 | [
"def",
"pubsub_pop_message",
"(",
"self",
",",
"deadline",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"subscribed",
":",
"excep",
"=",
"ClientError",
"(",
"\"you must subscribe before using \"",
"\"pubsub_pop_message\"",
")",
"raise",
"tornado",
".",
"gen",
... | f9dc883e46eb5971b62eab38346319757e5f900f |
train | _get_flat_ids | This is a helper function to recover the coordinates of regions that have
been labeled within an image. This function efficiently computes the
coordinate of all regions and returns the information in a memory-efficient
manner.
Parameters
-----------
assigned : ndarray[ndim=2, dtype=int]
... | pydem/dem_processing.py | def _get_flat_ids(assigned):
"""
This is a helper function to recover the coordinates of regions that have
been labeled within an image. This function efficiently computes the
coordinate of all regions and returns the information in a memory-efficient
manner.
Parameters
-----------
assi... | def _get_flat_ids(assigned):
"""
This is a helper function to recover the coordinates of regions that have
been labeled within an image. This function efficiently computes the
coordinate of all regions and returns the information in a memory-efficient
manner.
Parameters
-----------
assi... | [
"This",
"is",
"a",
"helper",
"function",
"to",
"recover",
"the",
"coordinates",
"of",
"regions",
"that",
"have",
"been",
"labeled",
"within",
"an",
"image",
".",
"This",
"function",
"efficiently",
"computes",
"the",
"coordinate",
"of",
"all",
"regions",
"and",... | creare-com/pydem | python | https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/dem_processing.py#L2364-L2404 | [
"def",
"_get_flat_ids",
"(",
"assigned",
")",
":",
"# MPU optimization:",
"# Let's segment the regions and store in a sparse format",
"# First, let's use where once to find all the information we want",
"ids_labels",
"=",
"np",
".",
"arange",
"(",
"len",
"(",
"assigned",
".",
"... | c2fc8d84cfb411df84f71a6dec9edc4b544f710a |
train | _tarboton_slopes_directions | Calculate the slopes and directions based on the 8 sections from
Tarboton http://www.neng.usu.edu/cee/faculty/dtarb/96wr03137.pdf | pydem/dem_processing.py | def _tarboton_slopes_directions(data, dX, dY, facets, ang_adj):
"""
Calculate the slopes and directions based on the 8 sections from
Tarboton http://www.neng.usu.edu/cee/faculty/dtarb/96wr03137.pdf
"""
shp = np.array(data.shape) - 1
direction = np.full(data.shape, FLAT_ID_INT, 'float64')
m... | def _tarboton_slopes_directions(data, dX, dY, facets, ang_adj):
"""
Calculate the slopes and directions based on the 8 sections from
Tarboton http://www.neng.usu.edu/cee/faculty/dtarb/96wr03137.pdf
"""
shp = np.array(data.shape) - 1
direction = np.full(data.shape, FLAT_ID_INT, 'float64')
m... | [
"Calculate",
"the",
"slopes",
"and",
"directions",
"based",
"on",
"the",
"8",
"sections",
"from",
"Tarboton",
"http",
":",
"//",
"www",
".",
"neng",
".",
"usu",
".",
"edu",
"/",
"cee",
"/",
"faculty",
"/",
"dtarb",
"/",
"96wr03137",
".",
"pdf"
] | creare-com/pydem | python | https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/dem_processing.py#L2406-L2554 | [
"def",
"_tarboton_slopes_directions",
"(",
"data",
",",
"dX",
",",
"dY",
",",
"facets",
",",
"ang_adj",
")",
":",
"shp",
"=",
"np",
".",
"array",
"(",
"data",
".",
"shape",
")",
"-",
"1",
"direction",
"=",
"np",
".",
"full",
"(",
"data",
".",
"shap... | c2fc8d84cfb411df84f71a6dec9edc4b544f710a |
train | _get_d1_d2 | This finds the distances along the patch (within the eight neighboring
pixels around a central pixel) given the difference in x and y coordinates
of the real image. This is the function that allows real coordinates to be
used when calculating the magnitude and directions of slopes. | pydem/dem_processing.py | def _get_d1_d2(dX, dY, ind, e1, e2, shp, topbot=None):
"""
This finds the distances along the patch (within the eight neighboring
pixels around a central pixel) given the difference in x and y coordinates
of the real image. This is the function that allows real coordinates to be
used when calculatin... | def _get_d1_d2(dX, dY, ind, e1, e2, shp, topbot=None):
"""
This finds the distances along the patch (within the eight neighboring
pixels around a central pixel) given the difference in x and y coordinates
of the real image. This is the function that allows real coordinates to be
used when calculatin... | [
"This",
"finds",
"the",
"distances",
"along",
"the",
"patch",
"(",
"within",
"the",
"eight",
"neighboring",
"pixels",
"around",
"a",
"central",
"pixel",
")",
"given",
"the",
"difference",
"in",
"x",
"and",
"y",
"coordinates",
"of",
"the",
"real",
"image",
... | creare-com/pydem | python | https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/dem_processing.py#L2556-L2589 | [
"def",
"_get_d1_d2",
"(",
"dX",
",",
"dY",
",",
"ind",
",",
"e1",
",",
"e2",
",",
"shp",
",",
"topbot",
"=",
"None",
")",
":",
"if",
"topbot",
"==",
"None",
":",
"if",
"ind",
"in",
"[",
"0",
",",
"3",
",",
"4",
",",
"7",
"]",
":",
"d1",
"... | c2fc8d84cfb411df84f71a6dec9edc4b544f710a |
train | _calc_direction | This function gives the magnitude and direction of the slope based on
Tarboton's D_\infty method. This is a helper-function to
_tarboton_slopes_directions | pydem/dem_processing.py | def _calc_direction(data, mag, direction, ang, d1, d2, theta,
slc0, slc1, slc2):
"""
This function gives the magnitude and direction of the slope based on
Tarboton's D_\infty method. This is a helper-function to
_tarboton_slopes_directions
"""
data0 = data[slc0]
data... | def _calc_direction(data, mag, direction, ang, d1, d2, theta,
slc0, slc1, slc2):
"""
This function gives the magnitude and direction of the slope based on
Tarboton's D_\infty method. This is a helper-function to
_tarboton_slopes_directions
"""
data0 = data[slc0]
data... | [
"This",
"function",
"gives",
"the",
"magnitude",
"and",
"direction",
"of",
"the",
"slope",
"based",
"on",
"Tarboton",
"s",
"D_",
"\\",
"infty",
"method",
".",
"This",
"is",
"a",
"helper",
"-",
"function",
"to",
"_tarboton_slopes_directions"
] | creare-com/pydem | python | https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/dem_processing.py#L2593-L2638 | [
"def",
"_calc_direction",
"(",
"data",
",",
"mag",
",",
"direction",
",",
"ang",
",",
"d1",
",",
"d2",
",",
"theta",
",",
"slc0",
",",
"slc1",
",",
"slc2",
")",
":",
"data0",
"=",
"data",
"[",
"slc0",
"]",
"data1",
"=",
"data",
"[",
"slc1",
"]",
... | c2fc8d84cfb411df84f71a6dec9edc4b544f710a |
train | TileEdge.get | Returns an edge given a particular key
Parmeters
----------
key : tuple
(te, be, le, re) tuple that identifies a tile
side : str
top, bottom, left, or right, which edge to return | pydem/dem_processing.py | def get(self, key, side):
"""
Returns an edge given a particular key
Parmeters
----------
key : tuple
(te, be, le, re) tuple that identifies a tile
side : str
top, bottom, left, or right, which edge to return
"""
return getattr(self... | def get(self, key, side):
"""
Returns an edge given a particular key
Parmeters
----------
key : tuple
(te, be, le, re) tuple that identifies a tile
side : str
top, bottom, left, or right, which edge to return
"""
return getattr(self... | [
"Returns",
"an",
"edge",
"given",
"a",
"particular",
"key",
"Parmeters",
"----------",
"key",
":",
"tuple",
"(",
"te",
"be",
"le",
"re",
")",
"tuple",
"that",
"identifies",
"a",
"tile",
"side",
":",
"str",
"top",
"bottom",
"left",
"or",
"right",
"which",... | creare-com/pydem | python | https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/dem_processing.py#L234-L244 | [
"def",
"get",
"(",
"self",
",",
"key",
",",
"side",
")",
":",
"return",
"getattr",
"(",
"self",
",",
"side",
")",
".",
"ravel",
"(",
")",
"[",
"self",
".",
"keys",
"[",
"key",
"]",
"]"
] | c2fc8d84cfb411df84f71a6dec9edc4b544f710a |
train | TileEdge.set_i | Assigns data on the i'th tile to the data 'field' of the 'side'
edge of that tile | pydem/dem_processing.py | def set_i(self, i, data, field, side):
""" Assigns data on the i'th tile to the data 'field' of the 'side'
edge of that tile
"""
edge = self.get_i(i, side)
setattr(edge, field, data[edge.slice]) | def set_i(self, i, data, field, side):
""" Assigns data on the i'th tile to the data 'field' of the 'side'
edge of that tile
"""
edge = self.get_i(i, side)
setattr(edge, field, data[edge.slice]) | [
"Assigns",
"data",
"on",
"the",
"i",
"th",
"tile",
"to",
"the",
"data",
"field",
"of",
"the",
"side",
"edge",
"of",
"that",
"tile"
] | creare-com/pydem | python | https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/dem_processing.py#L265-L270 | [
"def",
"set_i",
"(",
"self",
",",
"i",
",",
"data",
",",
"field",
",",
"side",
")",
":",
"edge",
"=",
"self",
".",
"get_i",
"(",
"i",
",",
"side",
")",
"setattr",
"(",
"edge",
",",
"field",
",",
"data",
"[",
"edge",
".",
"slice",
"]",
")"
] | c2fc8d84cfb411df84f71a6dec9edc4b544f710a |
train | TileEdge.set_sides | Assign data on the 'key' tile to all the edges | pydem/dem_processing.py | def set_sides(self, key, data, field, local=False):
"""
Assign data on the 'key' tile to all the edges
"""
for side in ['left', 'right', 'top', 'bottom']:
self.set(key, data, field, side, local) | def set_sides(self, key, data, field, local=False):
"""
Assign data on the 'key' tile to all the edges
"""
for side in ['left', 'right', 'top', 'bottom']:
self.set(key, data, field, side, local) | [
"Assign",
"data",
"on",
"the",
"key",
"tile",
"to",
"all",
"the",
"edges"
] | creare-com/pydem | python | https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/dem_processing.py#L272-L277 | [
"def",
"set_sides",
"(",
"self",
",",
"key",
",",
"data",
",",
"field",
",",
"local",
"=",
"False",
")",
":",
"for",
"side",
"in",
"[",
"'left'",
",",
"'right'",
",",
"'top'",
",",
"'bottom'",
"]",
":",
"self",
".",
"set",
"(",
"key",
",",
"data"... | c2fc8d84cfb411df84f71a6dec9edc4b544f710a |
train | TileEdge.set_neighbor_data | Assign data from the 'key' tile to the edge on the
neighboring tile which is on the 'neighbor_side' of the 'key' tile.
The data is assigned to the 'field' attribute of the neihboring tile's
edge. | pydem/dem_processing.py | def set_neighbor_data(self, neighbor_side, data, key, field):
"""
Assign data from the 'key' tile to the edge on the
neighboring tile which is on the 'neighbor_side' of the 'key' tile.
The data is assigned to the 'field' attribute of the neihboring tile's
edge.
"""
... | def set_neighbor_data(self, neighbor_side, data, key, field):
"""
Assign data from the 'key' tile to the edge on the
neighboring tile which is on the 'neighbor_side' of the 'key' tile.
The data is assigned to the 'field' attribute of the neihboring tile's
edge.
"""
... | [
"Assign",
"data",
"from",
"the",
"key",
"tile",
"to",
"the",
"edge",
"on",
"the",
"neighboring",
"tile",
"which",
"is",
"on",
"the",
"neighbor_side",
"of",
"the",
"key",
"tile",
".",
"The",
"data",
"is",
"assigned",
"to",
"the",
"field",
"attribute",
"of... | creare-com/pydem | python | https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/dem_processing.py#L279-L316 | [
"def",
"set_neighbor_data",
"(",
"self",
",",
"neighbor_side",
",",
"data",
",",
"key",
",",
"field",
")",
":",
"i",
"=",
"self",
".",
"keys",
"[",
"key",
"]",
"found",
"=",
"False",
"sides",
"=",
"[",
"]",
"if",
"'left'",
"in",
"neighbor_side",
":",... | c2fc8d84cfb411df84f71a6dec9edc4b544f710a |
train | TileEdge.set_all_neighbors_data | Given they 'key' tile's data, assigns this information to all
neighboring tiles | pydem/dem_processing.py | def set_all_neighbors_data(self, data, done, key):
"""
Given they 'key' tile's data, assigns this information to all
neighboring tiles
"""
# The order of this for loop is important because the topleft gets
# it's data from the left neighbor, which should have already bee... | def set_all_neighbors_data(self, data, done, key):
"""
Given they 'key' tile's data, assigns this information to all
neighboring tiles
"""
# The order of this for loop is important because the topleft gets
# it's data from the left neighbor, which should have already bee... | [
"Given",
"they",
"key",
"tile",
"s",
"data",
"assigns",
"this",
"information",
"to",
"all",
"neighboring",
"tiles"
] | creare-com/pydem | python | https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/dem_processing.py#L318-L330 | [
"def",
"set_all_neighbors_data",
"(",
"self",
",",
"data",
",",
"done",
",",
"key",
")",
":",
"# The order of this for loop is important because the topleft gets",
"# it's data from the left neighbor, which should have already been",
"# updated...",
"for",
"side",
"in",
"[",
"'... | c2fc8d84cfb411df84f71a6dec9edc4b544f710a |
train | TileEdge.fill_n_todo | Calculate and record the number of edge pixels left to do on each tile | pydem/dem_processing.py | def fill_n_todo(self):
"""
Calculate and record the number of edge pixels left to do on each tile
"""
left = self.left
right = self.right
top = self.top
bottom = self.bottom
for i in xrange(self.n_chunks):
self.n_todo.ravel()[i] = np.sum([left.... | def fill_n_todo(self):
"""
Calculate and record the number of edge pixels left to do on each tile
"""
left = self.left
right = self.right
top = self.top
bottom = self.bottom
for i in xrange(self.n_chunks):
self.n_todo.ravel()[i] = np.sum([left.... | [
"Calculate",
"and",
"record",
"the",
"number",
"of",
"edge",
"pixels",
"left",
"to",
"do",
"on",
"each",
"tile"
] | creare-com/pydem | python | https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/dem_processing.py#L332-L344 | [
"def",
"fill_n_todo",
"(",
"self",
")",
":",
"left",
"=",
"self",
".",
"left",
"right",
"=",
"self",
".",
"right",
"top",
"=",
"self",
".",
"top",
"bottom",
"=",
"self",
".",
"bottom",
"for",
"i",
"in",
"xrange",
"(",
"self",
".",
"n_chunks",
")",
... | c2fc8d84cfb411df84f71a6dec9edc4b544f710a |
train | TileEdge.fill_n_done | Calculate and record the number of edge pixels that are done one each
tile. | pydem/dem_processing.py | def fill_n_done(self):
"""
Calculate and record the number of edge pixels that are done one each
tile.
"""
left = self.left
right = self.right
top = self.top
bottom = self.bottom
for i in xrange(self.n_chunks):
self.n_done.ravel()[i] = ... | def fill_n_done(self):
"""
Calculate and record the number of edge pixels that are done one each
tile.
"""
left = self.left
right = self.right
top = self.top
bottom = self.bottom
for i in xrange(self.n_chunks):
self.n_done.ravel()[i] = ... | [
"Calculate",
"and",
"record",
"the",
"number",
"of",
"edge",
"pixels",
"that",
"are",
"done",
"one",
"each",
"tile",
"."
] | creare-com/pydem | python | https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/dem_processing.py#L346-L359 | [
"def",
"fill_n_done",
"(",
"self",
")",
":",
"left",
"=",
"self",
".",
"left",
"right",
"=",
"self",
".",
"right",
"top",
"=",
"self",
".",
"top",
"bottom",
"=",
"self",
".",
"bottom",
"for",
"i",
"in",
"xrange",
"(",
"self",
".",
"n_chunks",
")",
... | c2fc8d84cfb411df84f71a6dec9edc4b544f710a |
train | TileEdge.fill_percent_done | Calculate the percentage of edge pixels that would be done if the tile
was reprocessed. This is done for each tile. | pydem/dem_processing.py | def fill_percent_done(self):
"""
Calculate the percentage of edge pixels that would be done if the tile
was reprocessed. This is done for each tile.
"""
left = self.left
right = self.right
top = self.top
bottom = self.bottom
for i in xrange(self.n_... | def fill_percent_done(self):
"""
Calculate the percentage of edge pixels that would be done if the tile
was reprocessed. This is done for each tile.
"""
left = self.left
right = self.right
top = self.top
bottom = self.bottom
for i in xrange(self.n_... | [
"Calculate",
"the",
"percentage",
"of",
"edge",
"pixels",
"that",
"would",
"be",
"done",
"if",
"the",
"tile",
"was",
"reprocessed",
".",
"This",
"is",
"done",
"for",
"each",
"tile",
"."
] | creare-com/pydem | python | https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/dem_processing.py#L361-L380 | [
"def",
"fill_percent_done",
"(",
"self",
")",
":",
"left",
"=",
"self",
".",
"left",
"right",
"=",
"self",
".",
"right",
"top",
"=",
"self",
".",
"top",
"bottom",
"=",
"self",
".",
"bottom",
"for",
"i",
"in",
"xrange",
"(",
"self",
".",
"n_chunks",
... | c2fc8d84cfb411df84f71a6dec9edc4b544f710a |
train | TileEdge.fill_array | Given a full array (for the while image), fill it with the data on
the edges. | pydem/dem_processing.py | def fill_array(self, array, field, add=False, maximize=False):
"""
Given a full array (for the while image), fill it with the data on
the edges.
"""
self.fix_shapes()
for i in xrange(self.n_chunks):
for side in ['left', 'right', 'top', 'bottom']:
... | def fill_array(self, array, field, add=False, maximize=False):
"""
Given a full array (for the while image), fill it with the data on
the edges.
"""
self.fix_shapes()
for i in xrange(self.n_chunks):
for side in ['left', 'right', 'top', 'bottom']:
... | [
"Given",
"a",
"full",
"array",
"(",
"for",
"the",
"while",
"image",
")",
"fill",
"it",
"with",
"the",
"data",
"on",
"the",
"edges",
"."
] | creare-com/pydem | python | https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/dem_processing.py#L382-L398 | [
"def",
"fill_array",
"(",
"self",
",",
"array",
",",
"field",
",",
"add",
"=",
"False",
",",
"maximize",
"=",
"False",
")",
":",
"self",
".",
"fix_shapes",
"(",
")",
"for",
"i",
"in",
"xrange",
"(",
"self",
".",
"n_chunks",
")",
":",
"for",
"side",... | c2fc8d84cfb411df84f71a6dec9edc4b544f710a |
train | TileEdge.fix_shapes | Fixes the shape of the data fields on edges. Left edges should be
column vectors, and top edges should be row vectors, for example. | pydem/dem_processing.py | def fix_shapes(self):
"""
Fixes the shape of the data fields on edges. Left edges should be
column vectors, and top edges should be row vectors, for example.
"""
for i in xrange(self.n_chunks):
for side in ['left', 'right', 'top', 'bottom']:
edge = get... | def fix_shapes(self):
"""
Fixes the shape of the data fields on edges. Left edges should be
column vectors, and top edges should be row vectors, for example.
"""
for i in xrange(self.n_chunks):
for side in ['left', 'right', 'top', 'bottom']:
edge = get... | [
"Fixes",
"the",
"shape",
"of",
"the",
"data",
"fields",
"on",
"edges",
".",
"Left",
"edges",
"should",
"be",
"column",
"vectors",
"and",
"top",
"edges",
"should",
"be",
"row",
"vectors",
"for",
"example",
"."
] | creare-com/pydem | python | https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/dem_processing.py#L400-L414 | [
"def",
"fix_shapes",
"(",
"self",
")",
":",
"for",
"i",
"in",
"xrange",
"(",
"self",
".",
"n_chunks",
")",
":",
"for",
"side",
"in",
"[",
"'left'",
",",
"'right'",
",",
"'top'",
",",
"'bottom'",
"]",
":",
"edge",
"=",
"getattr",
"(",
"self",
",",
... | c2fc8d84cfb411df84f71a6dec9edc4b544f710a |
train | TileEdge.find_best_candidate | Determine which tile, when processed, would complete the largest
percentage of unresolved edge pixels. This is a heuristic function
and does not give the optimal tile. | pydem/dem_processing.py | def find_best_candidate(self):
"""
Determine which tile, when processed, would complete the largest
percentage of unresolved edge pixels. This is a heuristic function
and does not give the optimal tile.
"""
self.fill_percent_done()
i_b = np.argmax(self.percent_don... | def find_best_candidate(self):
"""
Determine which tile, when processed, would complete the largest
percentage of unresolved edge pixels. This is a heuristic function
and does not give the optimal tile.
"""
self.fill_percent_done()
i_b = np.argmax(self.percent_don... | [
"Determine",
"which",
"tile",
"when",
"processed",
"would",
"complete",
"the",
"largest",
"percentage",
"of",
"unresolved",
"edge",
"pixels",
".",
"This",
"is",
"a",
"heuristic",
"function",
"and",
"does",
"not",
"give",
"the",
"optimal",
"tile",
"."
] | creare-com/pydem | python | https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/dem_processing.py#L416-L433 | [
"def",
"find_best_candidate",
"(",
"self",
")",
":",
"self",
".",
"fill_percent_done",
"(",
")",
"i_b",
"=",
"np",
".",
"argmax",
"(",
"self",
".",
"percent_done",
".",
"ravel",
"(",
")",
")",
"if",
"self",
".",
"percent_done",
".",
"ravel",
"(",
")",
... | c2fc8d84cfb411df84f71a6dec9edc4b544f710a |
train | DEMProcessor.save_array | Standard array saving routine
Parameters
-----------
array : array
Array to save to file
name : str, optional
Default 'array.tif'. Filename of array to save. Over-writes
partname.
partname : str, optional
Part of the filename to sa... | pydem/dem_processing.py | def save_array(self, array, name=None, partname=None, rootpath='.',
raw=False, as_int=True):
"""
Standard array saving routine
Parameters
-----------
array : array
Array to save to file
name : str, optional
Default 'array.tif'. ... | def save_array(self, array, name=None, partname=None, rootpath='.',
raw=False, as_int=True):
"""
Standard array saving routine
Parameters
-----------
array : array
Array to save to file
name : str, optional
Default 'array.tif'. ... | [
"Standard",
"array",
"saving",
"routine"
] | creare-com/pydem | python | https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/dem_processing.py#L631-L684 | [
"def",
"save_array",
"(",
"self",
",",
"array",
",",
"name",
"=",
"None",
",",
"partname",
"=",
"None",
",",
"rootpath",
"=",
"'.'",
",",
"raw",
"=",
"False",
",",
"as_int",
"=",
"True",
")",
":",
"if",
"name",
"is",
"None",
"and",
"partname",
"is"... | c2fc8d84cfb411df84f71a6dec9edc4b544f710a |
train | DEMProcessor.save_uca | Saves the upstream contributing area to a file | pydem/dem_processing.py | def save_uca(self, rootpath, raw=False, as_int=False):
""" Saves the upstream contributing area to a file
"""
self.save_array(self.uca, None, 'uca', rootpath, raw, as_int=as_int) | def save_uca(self, rootpath, raw=False, as_int=False):
""" Saves the upstream contributing area to a file
"""
self.save_array(self.uca, None, 'uca', rootpath, raw, as_int=as_int) | [
"Saves",
"the",
"upstream",
"contributing",
"area",
"to",
"a",
"file"
] | creare-com/pydem | python | https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/dem_processing.py#L686-L689 | [
"def",
"save_uca",
"(",
"self",
",",
"rootpath",
",",
"raw",
"=",
"False",
",",
"as_int",
"=",
"False",
")",
":",
"self",
".",
"save_array",
"(",
"self",
".",
"uca",
",",
"None",
",",
"'uca'",
",",
"rootpath",
",",
"raw",
",",
"as_int",
"=",
"as_in... | c2fc8d84cfb411df84f71a6dec9edc4b544f710a |
train | DEMProcessor.save_twi | Saves the topographic wetness index to a file | pydem/dem_processing.py | def save_twi(self, rootpath, raw=False, as_int=True):
""" Saves the topographic wetness index to a file
"""
self.twi = np.ma.masked_array(self.twi, mask=self.twi <= 0,
fill_value=-9999)
# self.twi = self.twi.filled()
self.twi[self.flats] = 0... | def save_twi(self, rootpath, raw=False, as_int=True):
""" Saves the topographic wetness index to a file
"""
self.twi = np.ma.masked_array(self.twi, mask=self.twi <= 0,
fill_value=-9999)
# self.twi = self.twi.filled()
self.twi[self.flats] = 0... | [
"Saves",
"the",
"topographic",
"wetness",
"index",
"to",
"a",
"file"
] | creare-com/pydem | python | https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/dem_processing.py#L691-L700 | [
"def",
"save_twi",
"(",
"self",
",",
"rootpath",
",",
"raw",
"=",
"False",
",",
"as_int",
"=",
"True",
")",
":",
"self",
".",
"twi",
"=",
"np",
".",
"ma",
".",
"masked_array",
"(",
"self",
".",
"twi",
",",
"mask",
"=",
"self",
".",
"twi",
"<=",
... | c2fc8d84cfb411df84f71a6dec9edc4b544f710a |
train | DEMProcessor.save_slope | Saves the magnitude of the slope to a file | pydem/dem_processing.py | def save_slope(self, rootpath, raw=False, as_int=False):
""" Saves the magnitude of the slope to a file
"""
self.save_array(self.mag, None, 'mag', rootpath, raw, as_int=as_int) | def save_slope(self, rootpath, raw=False, as_int=False):
""" Saves the magnitude of the slope to a file
"""
self.save_array(self.mag, None, 'mag', rootpath, raw, as_int=as_int) | [
"Saves",
"the",
"magnitude",
"of",
"the",
"slope",
"to",
"a",
"file"
] | creare-com/pydem | python | https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/dem_processing.py#L702-L705 | [
"def",
"save_slope",
"(",
"self",
",",
"rootpath",
",",
"raw",
"=",
"False",
",",
"as_int",
"=",
"False",
")",
":",
"self",
".",
"save_array",
"(",
"self",
".",
"mag",
",",
"None",
",",
"'mag'",
",",
"rootpath",
",",
"raw",
",",
"as_int",
"=",
"as_... | c2fc8d84cfb411df84f71a6dec9edc4b544f710a |
train | DEMProcessor.save_direction | Saves the direction of the slope to a file | pydem/dem_processing.py | def save_direction(self, rootpath, raw=False, as_int=False):
""" Saves the direction of the slope to a file
"""
self.save_array(self.direction, None, 'ang', rootpath, raw, as_int=as_int) | def save_direction(self, rootpath, raw=False, as_int=False):
""" Saves the direction of the slope to a file
"""
self.save_array(self.direction, None, 'ang', rootpath, raw, as_int=as_int) | [
"Saves",
"the",
"direction",
"of",
"the",
"slope",
"to",
"a",
"file"
] | creare-com/pydem | python | https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/dem_processing.py#L707-L710 | [
"def",
"save_direction",
"(",
"self",
",",
"rootpath",
",",
"raw",
"=",
"False",
",",
"as_int",
"=",
"False",
")",
":",
"self",
".",
"save_array",
"(",
"self",
".",
"direction",
",",
"None",
",",
"'ang'",
",",
"rootpath",
",",
"raw",
",",
"as_int",
"... | c2fc8d84cfb411df84f71a6dec9edc4b544f710a |
train | DEMProcessor.save_outputs | Saves TWI, UCA, magnitude and direction of slope to files. | pydem/dem_processing.py | def save_outputs(self, rootpath='.', raw=False):
"""Saves TWI, UCA, magnitude and direction of slope to files.
"""
self.save_twi(rootpath, raw)
self.save_uca(rootpath, raw)
self.save_slope(rootpath, raw)
self.save_direction(rootpath, raw) | def save_outputs(self, rootpath='.', raw=False):
"""Saves TWI, UCA, magnitude and direction of slope to files.
"""
self.save_twi(rootpath, raw)
self.save_uca(rootpath, raw)
self.save_slope(rootpath, raw)
self.save_direction(rootpath, raw) | [
"Saves",
"TWI",
"UCA",
"magnitude",
"and",
"direction",
"of",
"slope",
"to",
"files",
"."
] | creare-com/pydem | python | https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/dem_processing.py#L712-L718 | [
"def",
"save_outputs",
"(",
"self",
",",
"rootpath",
"=",
"'.'",
",",
"raw",
"=",
"False",
")",
":",
"self",
".",
"save_twi",
"(",
"rootpath",
",",
"raw",
")",
"self",
".",
"save_uca",
"(",
"rootpath",
",",
"raw",
")",
"self",
".",
"save_slope",
"(",... | c2fc8d84cfb411df84f71a6dec9edc4b544f710a |
train | DEMProcessor.load_array | Can only load files that were saved in the 'raw' format.
Loads previously computed field 'name' from file
Valid names are 'mag', 'direction', 'uca', 'twi' | pydem/dem_processing.py | def load_array(self, fn, name):
"""
Can only load files that were saved in the 'raw' format.
Loads previously computed field 'name' from file
Valid names are 'mag', 'direction', 'uca', 'twi'
"""
if os.path.exists(fn + '.npz'):
array = np.load(fn + '.npz')
... | def load_array(self, fn, name):
"""
Can only load files that were saved in the 'raw' format.
Loads previously computed field 'name' from file
Valid names are 'mag', 'direction', 'uca', 'twi'
"""
if os.path.exists(fn + '.npz'):
array = np.load(fn + '.npz')
... | [
"Can",
"only",
"load",
"files",
"that",
"were",
"saved",
"in",
"the",
"raw",
"format",
".",
"Loads",
"previously",
"computed",
"field",
"name",
"from",
"file",
"Valid",
"names",
"are",
"mag",
"direction",
"uca",
"twi"
] | creare-com/pydem | python | https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/dem_processing.py#L720-L737 | [
"def",
"load_array",
"(",
"self",
",",
"fn",
",",
"name",
")",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"fn",
"+",
"'.npz'",
")",
":",
"array",
"=",
"np",
".",
"load",
"(",
"fn",
"+",
"'.npz'",
")",
"try",
":",
"setattr",
"(",
"self",
... | c2fc8d84cfb411df84f71a6dec9edc4b544f710a |
train | DEMProcessor._get_chunk_edges | Given the size of the array, calculate and array that gives the
edges of chunks of nominal size, with specified overlap
Parameters
----------
NN : int
Size of array
chunk_size : int
Nominal size of chunks (chunk_size < NN)
chunk_overlap : int
... | pydem/dem_processing.py | def _get_chunk_edges(self, NN, chunk_size, chunk_overlap):
"""
Given the size of the array, calculate and array that gives the
edges of chunks of nominal size, with specified overlap
Parameters
----------
NN : int
Size of array
chunk_size : int
... | def _get_chunk_edges(self, NN, chunk_size, chunk_overlap):
"""
Given the size of the array, calculate and array that gives the
edges of chunks of nominal size, with specified overlap
Parameters
----------
NN : int
Size of array
chunk_size : int
... | [
"Given",
"the",
"size",
"of",
"the",
"array",
"calculate",
"and",
"array",
"that",
"gives",
"the",
"edges",
"of",
"chunks",
"of",
"nominal",
"size",
"with",
"specified",
"overlap",
"Parameters",
"----------",
"NN",
":",
"int",
"Size",
"of",
"array",
"chunk_s... | creare-com/pydem | python | https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/dem_processing.py#L754-L781 | [
"def",
"_get_chunk_edges",
"(",
"self",
",",
"NN",
",",
"chunk_size",
",",
"chunk_overlap",
")",
":",
"left_edge",
"=",
"np",
".",
"arange",
"(",
"0",
",",
"NN",
"-",
"chunk_overlap",
",",
"chunk_size",
")",
"left_edge",
"[",
"1",
":",
"]",
"-=",
"chun... | c2fc8d84cfb411df84f71a6dec9edc4b544f710a |
train | DEMProcessor._assign_chunk | Assign data from a chunk to the full array. The data in overlap regions
will not be assigned to the full array
Parameters
-----------
data : array
Unused array (except for shape) that has size of full tile
arr1 : array
Full size array to which data will b... | pydem/dem_processing.py | def _assign_chunk(self, data, arr1, arr2, te, be, le, re, ovr, add=False):
"""
Assign data from a chunk to the full array. The data in overlap regions
will not be assigned to the full array
Parameters
-----------
data : array
Unused array (except for shape) t... | def _assign_chunk(self, data, arr1, arr2, te, be, le, re, ovr, add=False):
"""
Assign data from a chunk to the full array. The data in overlap regions
will not be assigned to the full array
Parameters
-----------
data : array
Unused array (except for shape) t... | [
"Assign",
"data",
"from",
"a",
"chunk",
"to",
"the",
"full",
"array",
".",
"The",
"data",
"in",
"overlap",
"regions",
"will",
"not",
"be",
"assigned",
"to",
"the",
"full",
"array"
] | creare-com/pydem | python | https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/dem_processing.py#L783-L838 | [
"def",
"_assign_chunk",
"(",
"self",
",",
"data",
",",
"arr1",
",",
"arr2",
",",
"te",
",",
"be",
",",
"le",
",",
"re",
",",
"ovr",
",",
"add",
"=",
"False",
")",
":",
"if",
"te",
"==",
"0",
":",
"i1",
"=",
"0",
"else",
":",
"i1",
"=",
"ovr... | c2fc8d84cfb411df84f71a6dec9edc4b544f710a |
train | DEMProcessor.calc_slopes_directions | Calculates the magnitude and direction of slopes and fills
self.mag, self.direction | pydem/dem_processing.py | def calc_slopes_directions(self, plotflag=False):
"""
Calculates the magnitude and direction of slopes and fills
self.mag, self.direction
"""
# TODO minimum filter behavior with nans?
# fill/interpolate flats first
if self.fill_flats:
... | def calc_slopes_directions(self, plotflag=False):
"""
Calculates the magnitude and direction of slopes and fills
self.mag, self.direction
"""
# TODO minimum filter behavior with nans?
# fill/interpolate flats first
if self.fill_flats:
... | [
"Calculates",
"the",
"magnitude",
"and",
"direction",
"of",
"slopes",
"and",
"fills",
"self",
".",
"mag",
"self",
".",
"direction"
] | creare-com/pydem | python | https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/dem_processing.py#L936-L1018 | [
"def",
"calc_slopes_directions",
"(",
"self",
",",
"plotflag",
"=",
"False",
")",
":",
"# TODO minimum filter behavior with nans?",
"# fill/interpolate flats first",
"if",
"self",
".",
"fill_flats",
":",
"data",
"=",
"np",
".",
"ma",
".",
"filled",
"(",
"self",
".... | c2fc8d84cfb411df84f71a6dec9edc4b544f710a |
train | DEMProcessor._slopes_directions | Wrapper to pick between various algorithms | pydem/dem_processing.py | def _slopes_directions(self, data, dX, dY, method='tarboton'):
""" Wrapper to pick between various algorithms
"""
# %%
if method == 'tarboton':
return self._tarboton_slopes_directions(data, dX, dY)
elif method == 'central':
return self._central_slopes_dire... | def _slopes_directions(self, data, dX, dY, method='tarboton'):
""" Wrapper to pick between various algorithms
"""
# %%
if method == 'tarboton':
return self._tarboton_slopes_directions(data, dX, dY)
elif method == 'central':
return self._central_slopes_dire... | [
"Wrapper",
"to",
"pick",
"between",
"various",
"algorithms"
] | creare-com/pydem | python | https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/dem_processing.py#L1020-L1027 | [
"def",
"_slopes_directions",
"(",
"self",
",",
"data",
",",
"dX",
",",
"dY",
",",
"method",
"=",
"'tarboton'",
")",
":",
"# %%",
"if",
"method",
"==",
"'tarboton'",
":",
"return",
"self",
".",
"_tarboton_slopes_directions",
"(",
"data",
",",
"dX",
",",
"... | c2fc8d84cfb411df84f71a6dec9edc4b544f710a |
train | DEMProcessor._tarboton_slopes_directions | Calculate the slopes and directions based on the 8 sections from
Tarboton http://www.neng.usu.edu/cee/faculty/dtarb/96wr03137.pdf | pydem/dem_processing.py | def _tarboton_slopes_directions(self, data, dX, dY):
"""
Calculate the slopes and directions based on the 8 sections from
Tarboton http://www.neng.usu.edu/cee/faculty/dtarb/96wr03137.pdf
"""
return _tarboton_slopes_directions(data, dX, dY,
... | def _tarboton_slopes_directions(self, data, dX, dY):
"""
Calculate the slopes and directions based on the 8 sections from
Tarboton http://www.neng.usu.edu/cee/faculty/dtarb/96wr03137.pdf
"""
return _tarboton_slopes_directions(data, dX, dY,
... | [
"Calculate",
"the",
"slopes",
"and",
"directions",
"based",
"on",
"the",
"8",
"sections",
"from",
"Tarboton",
"http",
":",
"//",
"www",
".",
"neng",
".",
"usu",
".",
"edu",
"/",
"cee",
"/",
"faculty",
"/",
"dtarb",
"/",
"96wr03137",
".",
"pdf"
] | creare-com/pydem | python | https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/dem_processing.py#L1029-L1036 | [
"def",
"_tarboton_slopes_directions",
"(",
"self",
",",
"data",
",",
"dX",
",",
"dY",
")",
":",
"return",
"_tarboton_slopes_directions",
"(",
"data",
",",
"dX",
",",
"dY",
",",
"self",
".",
"facets",
",",
"self",
".",
"ang_adj",
")"
] | c2fc8d84cfb411df84f71a6dec9edc4b544f710a |
train | DEMProcessor._central_slopes_directions | Calculates magnitude/direction of slopes using central difference | pydem/dem_processing.py | def _central_slopes_directions(self, data, dX, dY):
"""
Calculates magnitude/direction of slopes using central difference
"""
shp = np.array(data.shape) - 1
direction = np.full(data.shape, FLAT_ID_INT, 'float64')
mag = np.full(direction, FLAT_ID_INT, 'float64')
... | def _central_slopes_directions(self, data, dX, dY):
"""
Calculates magnitude/direction of slopes using central difference
"""
shp = np.array(data.shape) - 1
direction = np.full(data.shape, FLAT_ID_INT, 'float64')
mag = np.full(direction, FLAT_ID_INT, 'float64')
... | [
"Calculates",
"magnitude",
"/",
"direction",
"of",
"slopes",
"using",
"central",
"difference"
] | creare-com/pydem | python | https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/dem_processing.py#L1038-L1054 | [
"def",
"_central_slopes_directions",
"(",
"self",
",",
"data",
",",
"dX",
",",
"dY",
")",
":",
"shp",
"=",
"np",
".",
"array",
"(",
"data",
".",
"shape",
")",
"-",
"1",
"direction",
"=",
"np",
".",
"full",
"(",
"data",
".",
"shape",
",",
"FLAT_ID_I... | c2fc8d84cfb411df84f71a6dec9edc4b544f710a |
train | DEMProcessor._find_flats_edges | Extend flats 1 square downstream
Flats on the downstream side of the flat might find a valid angle,
but that doesn't mean that it's a correct angle. We have to find
these and then set them equal to a flat | pydem/dem_processing.py | def _find_flats_edges(self, data, mag, direction):
"""
Extend flats 1 square downstream
Flats on the downstream side of the flat might find a valid angle,
but that doesn't mean that it's a correct angle. We have to find
these and then set them equal to a flat
"""
... | def _find_flats_edges(self, data, mag, direction):
"""
Extend flats 1 square downstream
Flats on the downstream side of the flat might find a valid angle,
but that doesn't mean that it's a correct angle. We have to find
these and then set them equal to a flat
"""
... | [
"Extend",
"flats",
"1",
"square",
"downstream",
"Flats",
"on",
"the",
"downstream",
"side",
"of",
"the",
"flat",
"might",
"find",
"a",
"valid",
"angle",
"but",
"that",
"doesn",
"t",
"mean",
"that",
"it",
"s",
"a",
"correct",
"angle",
".",
"We",
"have",
... | creare-com/pydem | python | https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/dem_processing.py#L1056-L1079 | [
"def",
"_find_flats_edges",
"(",
"self",
",",
"data",
",",
"mag",
",",
"direction",
")",
":",
"i12",
"=",
"np",
".",
"arange",
"(",
"data",
".",
"size",
")",
".",
"reshape",
"(",
"data",
".",
"shape",
")",
"flat",
"=",
"mag",
"==",
"FLAT_ID_INT",
"... | c2fc8d84cfb411df84f71a6dec9edc4b544f710a |
train | DEMProcessor.calc_uca | Calculates the upstream contributing area.
Parameters
----------
plotflag : bool, optional
Default False. If true will plot debugging plots. For large files,
this will be very slow
edge_init_data : list, optional
edge_init_data = [uca_data, done_data,... | pydem/dem_processing.py | def calc_uca(self, plotflag=False, edge_init_data=None, uca_init=None):
"""Calculates the upstream contributing area.
Parameters
----------
plotflag : bool, optional
Default False. If true will plot debugging plots. For large files,
this will be very slow
... | def calc_uca(self, plotflag=False, edge_init_data=None, uca_init=None):
"""Calculates the upstream contributing area.
Parameters
----------
plotflag : bool, optional
Default False. If true will plot debugging plots. For large files,
this will be very slow
... | [
"Calculates",
"the",
"upstream",
"contributing",
"area",
"."
] | creare-com/pydem | python | https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/dem_processing.py#L1081-L1344 | [
"def",
"calc_uca",
"(",
"self",
",",
"plotflag",
"=",
"False",
",",
"edge_init_data",
"=",
"None",
",",
"uca_init",
"=",
"None",
")",
":",
"if",
"self",
".",
"direction",
"is",
"None",
":",
"self",
".",
"calc_slopes_directions",
"(",
")",
"# Initialize the... | c2fc8d84cfb411df84f71a6dec9edc4b544f710a |
train | DEMProcessor.fix_edge_pixels | This function fixes the pixels on the very edge of the tile.
Drainage is calculated if the edge is downstream from the interior.
If there is data available on the edge (from edge_init_data, for eg)
then this data is used.
This is a bit of hack to take care of the edge-values. It could
... | pydem/dem_processing.py | def fix_edge_pixels(self, edge_init_data, edge_init_done, edge_init_todo):
"""
This function fixes the pixels on the very edge of the tile.
Drainage is calculated if the edge is downstream from the interior.
If there is data available on the edge (from edge_init_data, for eg)
the... | def fix_edge_pixels(self, edge_init_data, edge_init_done, edge_init_todo):
"""
This function fixes the pixels on the very edge of the tile.
Drainage is calculated if the edge is downstream from the interior.
If there is data available on the edge (from edge_init_data, for eg)
the... | [
"This",
"function",
"fixes",
"the",
"pixels",
"on",
"the",
"very",
"edge",
"of",
"the",
"tile",
".",
"Drainage",
"is",
"calculated",
"if",
"the",
"edge",
"is",
"downstream",
"from",
"the",
"interior",
".",
"If",
"there",
"is",
"data",
"available",
"on",
... | creare-com/pydem | python | https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/dem_processing.py#L1346-L1412 | [
"def",
"fix_edge_pixels",
"(",
"self",
",",
"edge_init_data",
",",
"edge_init_done",
",",
"edge_init_todo",
")",
":",
"data",
",",
"dX",
",",
"dY",
",",
"direction",
",",
"flats",
"=",
"self",
".",
"data",
",",
"self",
".",
"dX",
",",
"self",
".",
"dY"... | c2fc8d84cfb411df84f71a6dec9edc4b544f710a |
train | DEMProcessor._calc_uca_chunk_update | Calculates the upstream contributing area due to contributions from
the edges only. | pydem/dem_processing.py | def _calc_uca_chunk_update(self, data, dX, dY, direction, mag, flats,
tile_edge=None, i=None,
area_edges=None, edge_todo=None, edge_done=None,
plotflag=False):
"""
Calculates the upstream contributing area due t... | def _calc_uca_chunk_update(self, data, dX, dY, direction, mag, flats,
tile_edge=None, i=None,
area_edges=None, edge_todo=None, edge_done=None,
plotflag=False):
"""
Calculates the upstream contributing area due t... | [
"Calculates",
"the",
"upstream",
"contributing",
"area",
"due",
"to",
"contributions",
"from",
"the",
"edges",
"only",
"."
] | creare-com/pydem | python | https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/dem_processing.py#L1414-L1642 | [
"def",
"_calc_uca_chunk_update",
"(",
"self",
",",
"data",
",",
"dX",
",",
"dY",
",",
"direction",
",",
"mag",
",",
"flats",
",",
"tile_edge",
"=",
"None",
",",
"i",
"=",
"None",
",",
"area_edges",
"=",
"None",
",",
"edge_todo",
"=",
"None",
",",
"ed... | c2fc8d84cfb411df84f71a6dec9edc4b544f710a |
train | DEMProcessor._calc_uca_chunk | Calculates the upstream contributing area for the interior, and
includes edge contributions if they are provided through area_edges. | pydem/dem_processing.py | def _calc_uca_chunk(self, data, dX, dY, direction, mag, flats,
area_edges, plotflag=False, edge_todo_i_no_mask=True):
"""
Calculates the upstream contributing area for the interior, and
includes edge contributions if they are provided through area_edges.
"""
... | def _calc_uca_chunk(self, data, dX, dY, direction, mag, flats,
area_edges, plotflag=False, edge_todo_i_no_mask=True):
"""
Calculates the upstream contributing area for the interior, and
includes edge contributions if they are provided through area_edges.
"""
... | [
"Calculates",
"the",
"upstream",
"contributing",
"area",
"for",
"the",
"interior",
"and",
"includes",
"edge",
"contributions",
"if",
"they",
"are",
"provided",
"through",
"area_edges",
"."
] | creare-com/pydem | python | https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/dem_processing.py#L1644-L1761 | [
"def",
"_calc_uca_chunk",
"(",
"self",
",",
"data",
",",
"dX",
",",
"dY",
",",
"direction",
",",
"mag",
",",
"flats",
",",
"area_edges",
",",
"plotflag",
"=",
"False",
",",
"edge_todo_i_no_mask",
"=",
"True",
")",
":",
"# %%",
"# Figure out which section the... | c2fc8d84cfb411df84f71a6dec9edc4b544f710a |
train | DEMProcessor._drain_step | Does a single step of the upstream contributing area calculation.
Here the pixels in ids are drained downstream, the areas are updated
and the next set of pixels to drain are determined for the next round. | pydem/dem_processing.py | def _drain_step(self, A, ids, area, done, edge_todo):
"""
Does a single step of the upstream contributing area calculation.
Here the pixels in ids are drained downstream, the areas are updated
and the next set of pixels to drain are determined for the next round.
"""
# On... | def _drain_step(self, A, ids, area, done, edge_todo):
"""
Does a single step of the upstream contributing area calculation.
Here the pixels in ids are drained downstream, the areas are updated
and the next set of pixels to drain are determined for the next round.
"""
# On... | [
"Does",
"a",
"single",
"step",
"of",
"the",
"upstream",
"contributing",
"area",
"calculation",
".",
"Here",
"the",
"pixels",
"in",
"ids",
"are",
"drained",
"downstream",
"the",
"areas",
"are",
"updated",
"and",
"the",
"next",
"set",
"of",
"pixels",
"to",
"... | creare-com/pydem | python | https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/dem_processing.py#L1763-L1793 | [
"def",
"_drain_step",
"(",
"self",
",",
"A",
",",
"ids",
",",
"area",
",",
"done",
",",
"edge_todo",
")",
":",
"# Only drain to cells that have a contribution",
"A_todo",
"=",
"A",
"[",
":",
",",
"ids",
".",
"ravel",
"(",
")",
"]",
"colsum",
"=",
"np",
... | c2fc8d84cfb411df84f71a6dec9edc4b544f710a |
train | DEMProcessor._calc_uca_section_proportion | Given the direction, figure out which nodes the drainage will go
toward, and what proportion of the drainage goes to which node | pydem/dem_processing.py | def _calc_uca_section_proportion(self, data, dX, dY, direction, flats):
"""
Given the direction, figure out which nodes the drainage will go
toward, and what proportion of the drainage goes to which node
"""
shp = np.array(data.shape) - 1
facets = self.facets
adj... | def _calc_uca_section_proportion(self, data, dX, dY, direction, flats):
"""
Given the direction, figure out which nodes the drainage will go
toward, and what proportion of the drainage goes to which node
"""
shp = np.array(data.shape) - 1
facets = self.facets
adj... | [
"Given",
"the",
"direction",
"figure",
"out",
"which",
"nodes",
"the",
"drainage",
"will",
"go",
"toward",
"and",
"what",
"proportion",
"of",
"the",
"drainage",
"goes",
"to",
"which",
"node"
] | creare-com/pydem | python | https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/dem_processing.py#L1795-L1844 | [
"def",
"_calc_uca_section_proportion",
"(",
"self",
",",
"data",
",",
"dX",
",",
"dY",
",",
"direction",
",",
"flats",
")",
":",
"shp",
"=",
"np",
".",
"array",
"(",
"data",
".",
"shape",
")",
"-",
"1",
"facets",
"=",
"self",
".",
"facets",
"adjust",... | c2fc8d84cfb411df84f71a6dec9edc4b544f710a |
train | DEMProcessor._mk_adjacency_matrix | Calculates the adjacency of connectivity matrix. This matrix tells
which pixels drain to which.
For example, the pixel i, will recieve area from np.nonzero(A[i, :])
at the proportions given in A[i, :]. So, the row gives the pixel
drain to, and the columns the pixels drained from. | pydem/dem_processing.py | def _mk_adjacency_matrix(self, section, proportion, flats, elev, mag, dX, dY):
"""
Calculates the adjacency of connectivity matrix. This matrix tells
which pixels drain to which.
For example, the pixel i, will recieve area from np.nonzero(A[i, :])
at the proportions given in A[i... | def _mk_adjacency_matrix(self, section, proportion, flats, elev, mag, dX, dY):
"""
Calculates the adjacency of connectivity matrix. This matrix tells
which pixels drain to which.
For example, the pixel i, will recieve area from np.nonzero(A[i, :])
at the proportions given in A[i... | [
"Calculates",
"the",
"adjacency",
"of",
"connectivity",
"matrix",
".",
"This",
"matrix",
"tells",
"which",
"pixels",
"drain",
"to",
"which",
"."
] | creare-com/pydem | python | https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/dem_processing.py#L1846-L1908 | [
"def",
"_mk_adjacency_matrix",
"(",
"self",
",",
"section",
",",
"proportion",
",",
"flats",
",",
"elev",
",",
"mag",
",",
"dX",
",",
"dY",
")",
":",
"shp",
"=",
"section",
".",
"shape",
"mat_data",
"=",
"np",
".",
"row_stack",
"(",
"(",
"proportion",
... | c2fc8d84cfb411df84f71a6dec9edc4b544f710a |
train | DEMProcessor._mk_connectivity | Helper function for _mk_adjacency_matrix. Calculates the drainage
neighbors and proportions based on the direction. This deals with
non-flat regions in the image. In this case, each pixel can only
drain to either 1 or two neighbors. | pydem/dem_processing.py | def _mk_connectivity(self, section, i12, j1, j2):
"""
Helper function for _mk_adjacency_matrix. Calculates the drainage
neighbors and proportions based on the direction. This deals with
non-flat regions in the image. In this case, each pixel can only
drain to either 1 or two neig... | def _mk_connectivity(self, section, i12, j1, j2):
"""
Helper function for _mk_adjacency_matrix. Calculates the drainage
neighbors and proportions based on the direction. This deals with
non-flat regions in the image. In this case, each pixel can only
drain to either 1 or two neig... | [
"Helper",
"function",
"for",
"_mk_adjacency_matrix",
".",
"Calculates",
"the",
"drainage",
"neighbors",
"and",
"proportions",
"based",
"on",
"the",
"direction",
".",
"This",
"deals",
"with",
"non",
"-",
"flat",
"regions",
"in",
"the",
"image",
".",
"In",
"this... | creare-com/pydem | python | https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/dem_processing.py#L1910-L2007 | [
"def",
"_mk_connectivity",
"(",
"self",
",",
"section",
",",
"i12",
",",
"j1",
",",
"j2",
")",
":",
"shp",
"=",
"np",
".",
"array",
"(",
"section",
".",
"shape",
")",
"-",
"1",
"facets",
"=",
"self",
".",
"facets",
"for",
"ii",
",",
"facet",
"in"... | c2fc8d84cfb411df84f71a6dec9edc4b544f710a |
train | DEMProcessor._mk_connectivity_pits | Helper function for _mk_adjacency_matrix. This is a more general
version of _mk_adjacency_flats which drains pits and flats to nearby
but non-adjacent pixels. The slope magnitude (and flats mask) is
updated for these pits and flats so that the TWI can be computed. | pydem/dem_processing.py | def _mk_connectivity_pits(self, i12, flats, elev, mag, dX, dY):
"""
Helper function for _mk_adjacency_matrix. This is a more general
version of _mk_adjacency_flats which drains pits and flats to nearby
but non-adjacent pixels. The slope magnitude (and flats mask) is
updated for t... | def _mk_connectivity_pits(self, i12, flats, elev, mag, dX, dY):
"""
Helper function for _mk_adjacency_matrix. This is a more general
version of _mk_adjacency_flats which drains pits and flats to nearby
but non-adjacent pixels. The slope magnitude (and flats mask) is
updated for t... | [
"Helper",
"function",
"for",
"_mk_adjacency_matrix",
".",
"This",
"is",
"a",
"more",
"general",
"version",
"of",
"_mk_adjacency_flats",
"which",
"drains",
"pits",
"and",
"flats",
"to",
"nearby",
"but",
"non",
"-",
"adjacent",
"pixels",
".",
"The",
"slope",
"ma... | creare-com/pydem | python | https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/dem_processing.py#L2009-L2098 | [
"def",
"_mk_connectivity_pits",
"(",
"self",
",",
"i12",
",",
"flats",
",",
"elev",
",",
"mag",
",",
"dX",
",",
"dY",
")",
":",
"e",
"=",
"elev",
".",
"data",
".",
"ravel",
"(",
")",
"pit_i",
"=",
"[",
"]",
"pit_j",
"=",
"[",
"]",
"pit_prop",
"... | c2fc8d84cfb411df84f71a6dec9edc4b544f710a |
train | DEMProcessor._mk_connectivity_flats | Helper function for _mk_adjacency_matrix. This calcualtes the
connectivity for flat regions. Every pixel in the flat will drain
to a random pixel in the flat. This accumulates all the area in the
flat region to a single pixel. All that area is then drained from
that pixel to the surround... | pydem/dem_processing.py | def _mk_connectivity_flats(self, i12, j1, j2, mat_data, flats, elev, mag):
"""
Helper function for _mk_adjacency_matrix. This calcualtes the
connectivity for flat regions. Every pixel in the flat will drain
to a random pixel in the flat. This accumulates all the area in the
flat ... | def _mk_connectivity_flats(self, i12, j1, j2, mat_data, flats, elev, mag):
"""
Helper function for _mk_adjacency_matrix. This calcualtes the
connectivity for flat regions. Every pixel in the flat will drain
to a random pixel in the flat. This accumulates all the area in the
flat ... | [
"Helper",
"function",
"for",
"_mk_adjacency_matrix",
".",
"This",
"calcualtes",
"the",
"connectivity",
"for",
"flat",
"regions",
".",
"Every",
"pixel",
"in",
"the",
"flat",
"will",
"drain",
"to",
"a",
"random",
"pixel",
"in",
"the",
"flat",
".",
"This",
"acc... | creare-com/pydem | python | https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/dem_processing.py#L2100-L2235 | [
"def",
"_mk_connectivity_flats",
"(",
"self",
",",
"i12",
",",
"j1",
",",
"j2",
",",
"mat_data",
",",
"flats",
",",
"elev",
",",
"mag",
")",
":",
"nn",
",",
"mm",
"=",
"flats",
".",
"shape",
"NN",
"=",
"np",
".",
"prod",
"(",
"flats",
".",
"shape... | c2fc8d84cfb411df84f71a6dec9edc4b544f710a |
train | DEMProcessor.calc_twi | Calculates the topographic wetness index and saves the result in
self.twi.
Returns
-------
twi : array
Array giving the topographic wetness index at each pixel | pydem/dem_processing.py | def calc_twi(self):
"""
Calculates the topographic wetness index and saves the result in
self.twi.
Returns
-------
twi : array
Array giving the topographic wetness index at each pixel
"""
if self.uca is None:
self.calc_uca()
... | def calc_twi(self):
"""
Calculates the topographic wetness index and saves the result in
self.twi.
Returns
-------
twi : array
Array giving the topographic wetness index at each pixel
"""
if self.uca is None:
self.calc_uca()
... | [
"Calculates",
"the",
"topographic",
"wetness",
"index",
"and",
"saves",
"the",
"result",
"in",
"self",
".",
"twi",
"."
] | creare-com/pydem | python | https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/dem_processing.py#L2237-L2267 | [
"def",
"calc_twi",
"(",
"self",
")",
":",
"if",
"self",
".",
"uca",
"is",
"None",
":",
"self",
".",
"calc_uca",
"(",
")",
"gc",
".",
"collect",
"(",
")",
"# Just in case",
"min_area",
"=",
"self",
".",
"twi_min_area",
"min_slope",
"=",
"self",
".",
"... | c2fc8d84cfb411df84f71a6dec9edc4b544f710a |
train | DEMProcessor._plot_connectivity | A debug function used to plot the adjacency/connectivity matrix.
This is really just a light wrapper around _plot_connectivity_helper | pydem/dem_processing.py | def _plot_connectivity(self, A, data=None, lims=[None, None]):
"""
A debug function used to plot the adjacency/connectivity matrix.
This is really just a light wrapper around _plot_connectivity_helper
"""
if data is None:
data = self.data
B = A.tocoo()
... | def _plot_connectivity(self, A, data=None, lims=[None, None]):
"""
A debug function used to plot the adjacency/connectivity matrix.
This is really just a light wrapper around _plot_connectivity_helper
"""
if data is None:
data = self.data
B = A.tocoo()
... | [
"A",
"debug",
"function",
"used",
"to",
"plot",
"the",
"adjacency",
"/",
"connectivity",
"matrix",
".",
"This",
"is",
"really",
"just",
"a",
"light",
"wrapper",
"around",
"_plot_connectivity_helper"
] | creare-com/pydem | python | https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/dem_processing.py#L2269-L2279 | [
"def",
"_plot_connectivity",
"(",
"self",
",",
"A",
",",
"data",
"=",
"None",
",",
"lims",
"=",
"[",
"None",
",",
"None",
"]",
")",
":",
"if",
"data",
"is",
"None",
":",
"data",
"=",
"self",
".",
"data",
"B",
"=",
"A",
".",
"tocoo",
"(",
")",
... | c2fc8d84cfb411df84f71a6dec9edc4b544f710a |
train | DEMProcessor._plot_connectivity_helper | A debug function used to plot the adjacency/connectivity matrix. | pydem/dem_processing.py | def _plot_connectivity_helper(self, ii, ji, mat_datai, data, lims=[1, 8]):
"""
A debug function used to plot the adjacency/connectivity matrix.
"""
from matplotlib.pyplot import quiver, colorbar, clim, matshow
I = ~np.isnan(mat_datai) & (ji != -1) & (mat_datai >= 0)
mat_... | def _plot_connectivity_helper(self, ii, ji, mat_datai, data, lims=[1, 8]):
"""
A debug function used to plot the adjacency/connectivity matrix.
"""
from matplotlib.pyplot import quiver, colorbar, clim, matshow
I = ~np.isnan(mat_datai) & (ji != -1) & (mat_datai >= 0)
mat_... | [
"A",
"debug",
"function",
"used",
"to",
"plot",
"the",
"adjacency",
"/",
"connectivity",
"matrix",
"."
] | creare-com/pydem | python | https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/dem_processing.py#L2281-L2299 | [
"def",
"_plot_connectivity_helper",
"(",
"self",
",",
"ii",
",",
"ji",
",",
"mat_datai",
",",
"data",
",",
"lims",
"=",
"[",
"1",
",",
"8",
"]",
")",
":",
"from",
"matplotlib",
".",
"pyplot",
"import",
"quiver",
",",
"colorbar",
",",
"clim",
",",
"ma... | c2fc8d84cfb411df84f71a6dec9edc4b544f710a |
train | DEMProcessor._plot_debug_slopes_directions | A debug function to plot the direction calculated in various ways. | pydem/dem_processing.py | def _plot_debug_slopes_directions(self):
"""
A debug function to plot the direction calculated in various ways.
"""
# %%
from matplotlib.pyplot import matshow, colorbar, clim, title
matshow(self.direction / np.pi * 180); colorbar(); clim(0, 360)
title('Direction'... | def _plot_debug_slopes_directions(self):
"""
A debug function to plot the direction calculated in various ways.
"""
# %%
from matplotlib.pyplot import matshow, colorbar, clim, title
matshow(self.direction / np.pi * 180); colorbar(); clim(0, 360)
title('Direction'... | [
"A",
"debug",
"function",
"to",
"plot",
"the",
"direction",
"calculated",
"in",
"various",
"ways",
"."
] | creare-com/pydem | python | https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/dem_processing.py#L2301-L2361 | [
"def",
"_plot_debug_slopes_directions",
"(",
"self",
")",
":",
"# %%",
"from",
"matplotlib",
".",
"pyplot",
"import",
"matshow",
",",
"colorbar",
",",
"clim",
",",
"title",
"matshow",
"(",
"self",
".",
"direction",
"/",
"np",
".",
"pi",
"*",
"180",
")",
... | c2fc8d84cfb411df84f71a6dec9edc4b544f710a |
train | clean | Cleanup generated document artifacts. | tasks/docs.py | def clean(ctx, dry_run=False):
"""Cleanup generated document artifacts."""
basedir = ctx.sphinx.destdir or "build/docs"
cleanup_dirs([basedir], dry_run=dry_run) | def clean(ctx, dry_run=False):
"""Cleanup generated document artifacts."""
basedir = ctx.sphinx.destdir or "build/docs"
cleanup_dirs([basedir], dry_run=dry_run) | [
"Cleanup",
"generated",
"document",
"artifacts",
"."
] | click-contrib/click-configfile | python | https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/tasks/docs.py#L20-L23 | [
"def",
"clean",
"(",
"ctx",
",",
"dry_run",
"=",
"False",
")",
":",
"basedir",
"=",
"ctx",
".",
"sphinx",
".",
"destdir",
"or",
"\"build/docs\"",
"cleanup_dirs",
"(",
"[",
"basedir",
"]",
",",
"dry_run",
"=",
"dry_run",
")"
] | a616204cb9944125fd5051556f27a7ccef611e22 |
train | build | Build docs with sphinx-build | tasks/docs.py | def build(ctx, builder="html", options=""):
"""Build docs with sphinx-build"""
sourcedir = ctx.config.sphinx.sourcedir
destdir = Path(ctx.config.sphinx.destdir or "build")/builder
destdir = destdir.abspath()
with cd(sourcedir):
destdir_relative = Path(".").relpathto(destdir)
command ... | def build(ctx, builder="html", options=""):
"""Build docs with sphinx-build"""
sourcedir = ctx.config.sphinx.sourcedir
destdir = Path(ctx.config.sphinx.destdir or "build")/builder
destdir = destdir.abspath()
with cd(sourcedir):
destdir_relative = Path(".").relpathto(destdir)
command ... | [
"Build",
"docs",
"with",
"sphinx",
"-",
"build"
] | click-contrib/click-configfile | python | https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/tasks/docs.py#L30-L40 | [
"def",
"build",
"(",
"ctx",
",",
"builder",
"=",
"\"html\"",
",",
"options",
"=",
"\"\"",
")",
":",
"sourcedir",
"=",
"ctx",
".",
"config",
".",
"sphinx",
".",
"sourcedir",
"destdir",
"=",
"Path",
"(",
"ctx",
".",
"config",
".",
"sphinx",
".",
"destd... | a616204cb9944125fd5051556f27a7ccef611e22 |
train | browse | Open documentation in web browser. | tasks/docs.py | def browse(ctx):
"""Open documentation in web browser."""
page_html = Path(ctx.config.sphinx.destdir)/"html"/"index.html"
if not page_html.exists():
build(ctx, builder="html")
assert page_html.exists()
open_cmd = "open" # -- WORKS ON: MACOSX
if sys.platform.startswith("win"):
o... | def browse(ctx):
"""Open documentation in web browser."""
page_html = Path(ctx.config.sphinx.destdir)/"html"/"index.html"
if not page_html.exists():
build(ctx, builder="html")
assert page_html.exists()
open_cmd = "open" # -- WORKS ON: MACOSX
if sys.platform.startswith("win"):
o... | [
"Open",
"documentation",
"in",
"web",
"browser",
"."
] | click-contrib/click-configfile | python | https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/tasks/docs.py#L48-L57 | [
"def",
"browse",
"(",
"ctx",
")",
":",
"page_html",
"=",
"Path",
"(",
"ctx",
".",
"config",
".",
"sphinx",
".",
"destdir",
")",
"/",
"\"html\"",
"/",
"\"index.html\"",
"if",
"not",
"page_html",
".",
"exists",
"(",
")",
":",
"build",
"(",
"ctx",
",",
... | a616204cb9944125fd5051556f27a7ccef611e22 |
train | save | Save/update docs under destination directory. | tasks/docs.py | def save(ctx, dest="docs.html", format="html"):
"""Save/update docs under destination directory."""
print("STEP: Generate docs in HTML format")
build(ctx, builder=format)
print("STEP: Save docs under %s/" % dest)
source_dir = Path(ctx.config.sphinx.destdir)/format
Path(dest).rmtree_p()
sour... | def save(ctx, dest="docs.html", format="html"):
"""Save/update docs under destination directory."""
print("STEP: Generate docs in HTML format")
build(ctx, builder=format)
print("STEP: Save docs under %s/" % dest)
source_dir = Path(ctx.config.sphinx.destdir)/format
Path(dest).rmtree_p()
sour... | [
"Save",
"/",
"update",
"docs",
"under",
"destination",
"directory",
"."
] | click-contrib/click-configfile | python | https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/tasks/docs.py#L65-L81 | [
"def",
"save",
"(",
"ctx",
",",
"dest",
"=",
"\"docs.html\"",
",",
"format",
"=",
"\"html\"",
")",
":",
"print",
"(",
"\"STEP: Generate docs in HTML format\"",
")",
"build",
"(",
"ctx",
",",
"builder",
"=",
"format",
")",
"print",
"(",
"\"STEP: Save docs under... | a616204cb9944125fd5051556f27a7ccef611e22 |
train | find_neighbors | Find the tile neighbors based on filenames
Parameters
-----------
neighbors : dict
Dictionary that stores the neighbors. Format is
neighbors["source_file_name"]["side"] = "neighbor_source_file_name"
coords : list
List of coordinates determined from the filename.
See :py:... | pydem/processing_manager.py | def find_neighbors(neighbors, coords, I, source_files, f, sides):
"""Find the tile neighbors based on filenames
Parameters
-----------
neighbors : dict
Dictionary that stores the neighbors. Format is
neighbors["source_file_name"]["side"] = "neighbor_source_file_name"
coords : list
... | def find_neighbors(neighbors, coords, I, source_files, f, sides):
"""Find the tile neighbors based on filenames
Parameters
-----------
neighbors : dict
Dictionary that stores the neighbors. Format is
neighbors["source_file_name"]["side"] = "neighbor_source_file_name"
coords : list
... | [
"Find",
"the",
"tile",
"neighbors",
"based",
"on",
"filenames"
] | creare-com/pydem | python | https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/processing_manager.py#L74-L120 | [
"def",
"find_neighbors",
"(",
"neighbors",
",",
"coords",
",",
"I",
",",
"source_files",
",",
"f",
",",
"sides",
")",
":",
"for",
"i",
",",
"c1",
"in",
"enumerate",
"(",
"coords",
")",
":",
"me",
"=",
"source_files",
"[",
"I",
"[",
"i",
"]",
"]",
... | c2fc8d84cfb411df84f71a6dec9edc4b544f710a |
train | TileEdgeFile.set_neighbor_data | From the elevation filename, we can figure out and load the data and
done arrays. | pydem/processing_manager.py | def set_neighbor_data(self, elev_fn, dem_proc, interp=None):
"""
From the elevation filename, we can figure out and load the data and
done arrays.
"""
if interp is None:
interp = self.build_interpolator(dem_proc)
opp = {'top': 'bottom', 'left': 'right'}
... | def set_neighbor_data(self, elev_fn, dem_proc, interp=None):
"""
From the elevation filename, we can figure out and load the data and
done arrays.
"""
if interp is None:
interp = self.build_interpolator(dem_proc)
opp = {'top': 'bottom', 'left': 'right'}
... | [
"From",
"the",
"elevation",
"filename",
"we",
"can",
"figure",
"out",
"and",
"load",
"the",
"data",
"and",
"done",
"arrays",
"."
] | creare-com/pydem | python | https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/processing_manager.py#L453-L485 | [
"def",
"set_neighbor_data",
"(",
"self",
",",
"elev_fn",
",",
"dem_proc",
",",
"interp",
"=",
"None",
")",
":",
"if",
"interp",
"is",
"None",
":",
"interp",
"=",
"self",
".",
"build_interpolator",
"(",
"dem_proc",
")",
"opp",
"=",
"{",
"'top'",
":",
"'... | c2fc8d84cfb411df84f71a6dec9edc4b544f710a |
train | TileEdgeFile.update_edge_todo | Can figure out how to update the todo based on the elev filename | pydem/processing_manager.py | def update_edge_todo(self, elev_fn, dem_proc):
"""
Can figure out how to update the todo based on the elev filename
"""
for key in self.edges[elev_fn].keys():
self.edges[elev_fn][key].set_data('todo', data=dem_proc.edge_todo) | def update_edge_todo(self, elev_fn, dem_proc):
"""
Can figure out how to update the todo based on the elev filename
"""
for key in self.edges[elev_fn].keys():
self.edges[elev_fn][key].set_data('todo', data=dem_proc.edge_todo) | [
"Can",
"figure",
"out",
"how",
"to",
"update",
"the",
"todo",
"based",
"on",
"the",
"elev",
"filename"
] | creare-com/pydem | python | https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/processing_manager.py#L487-L492 | [
"def",
"update_edge_todo",
"(",
"self",
",",
"elev_fn",
",",
"dem_proc",
")",
":",
"for",
"key",
"in",
"self",
".",
"edges",
"[",
"elev_fn",
"]",
".",
"keys",
"(",
")",
":",
"self",
".",
"edges",
"[",
"elev_fn",
"]",
"[",
"key",
"]",
".",
"set_data... | c2fc8d84cfb411df84f71a6dec9edc4b544f710a |
train | TileEdgeFile.update_edges | After finishing a calculation, this will update the neighbors and the
todo for that tile | pydem/processing_manager.py | def update_edges(self, elev_fn, dem_proc):
"""
After finishing a calculation, this will update the neighbors and the
todo for that tile
"""
interp = self.build_interpolator(dem_proc)
self.update_edge_todo(elev_fn, dem_proc)
self.set_neighbor_data(elev_fn, dem_proc... | def update_edges(self, elev_fn, dem_proc):
"""
After finishing a calculation, this will update the neighbors and the
todo for that tile
"""
interp = self.build_interpolator(dem_proc)
self.update_edge_todo(elev_fn, dem_proc)
self.set_neighbor_data(elev_fn, dem_proc... | [
"After",
"finishing",
"a",
"calculation",
"this",
"will",
"update",
"the",
"neighbors",
"and",
"the",
"todo",
"for",
"that",
"tile"
] | creare-com/pydem | python | https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/processing_manager.py#L494-L501 | [
"def",
"update_edges",
"(",
"self",
",",
"elev_fn",
",",
"dem_proc",
")",
":",
"interp",
"=",
"self",
".",
"build_interpolator",
"(",
"dem_proc",
")",
"self",
".",
"update_edge_todo",
"(",
"elev_fn",
",",
"dem_proc",
")",
"self",
".",
"set_neighbor_data",
"(... | c2fc8d84cfb411df84f71a6dec9edc4b544f710a |
train | TileEdgeFile.get_edge_init_data | Creates the initialization data from the edge structure | pydem/processing_manager.py | def get_edge_init_data(self, fn, save_path=None):
"""
Creates the initialization data from the edge structure
"""
edge_init_data = {key: self.edges[fn][key].get('data') for key in
self.edges[fn].keys()}
edge_init_done = {key: self.edges[fn][key].get('do... | def get_edge_init_data(self, fn, save_path=None):
"""
Creates the initialization data from the edge structure
"""
edge_init_data = {key: self.edges[fn][key].get('data') for key in
self.edges[fn].keys()}
edge_init_done = {key: self.edges[fn][key].get('do... | [
"Creates",
"the",
"initialization",
"data",
"from",
"the",
"edge",
"structure"
] | creare-com/pydem | python | https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/processing_manager.py#L503-L514 | [
"def",
"get_edge_init_data",
"(",
"self",
",",
"fn",
",",
"save_path",
"=",
"None",
")",
":",
"edge_init_data",
"=",
"{",
"key",
":",
"self",
".",
"edges",
"[",
"fn",
"]",
"[",
"key",
"]",
".",
"get",
"(",
"'data'",
")",
"for",
"key",
"in",
"self",... | c2fc8d84cfb411df84f71a6dec9edc4b544f710a |
train | TileEdgeFile.find_best_candidate | Heuristically determines which tile should be recalculated based on
updated edge information. Presently does not check if that tile is
locked, which could lead to a parallel thread closing while one thread
continues to process tiles. | pydem/processing_manager.py | def find_best_candidate(self, elev_source_files=None):
"""
Heuristically determines which tile should be recalculated based on
updated edge information. Presently does not check if that tile is
locked, which could lead to a parallel thread closing while one thread
continues to pr... | def find_best_candidate(self, elev_source_files=None):
"""
Heuristically determines which tile should be recalculated based on
updated edge information. Presently does not check if that tile is
locked, which could lead to a parallel thread closing while one thread
continues to pr... | [
"Heuristically",
"determines",
"which",
"tile",
"should",
"be",
"recalculated",
"based",
"on",
"updated",
"edge",
"information",
".",
"Presently",
"does",
"not",
"check",
"if",
"that",
"tile",
"is",
"locked",
"which",
"could",
"lead",
"to",
"a",
"parallel",
"t... | creare-com/pydem | python | https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/processing_manager.py#L516-L555 | [
"def",
"find_best_candidate",
"(",
"self",
",",
"elev_source_files",
"=",
"None",
")",
":",
"self",
".",
"fill_percent_done",
"(",
")",
"i_b",
"=",
"np",
".",
"argmax",
"(",
"self",
".",
"percent_done",
".",
"values",
"(",
")",
")",
"if",
"self",
".",
... | c2fc8d84cfb411df84f71a6dec9edc4b544f710a |
train | ProcessManager.process_twi | Processes the TWI, along with any dependencies (like the slope and UCA)
Parameters
-----------
index : int/slice (optional)
Default: None - process all tiles in source directory. Otherwise,
will only process the index/indices of the files as listed in
self.el... | pydem/processing_manager.py | def process_twi(self, index=None, do_edges=False, skip_uca_twi=False):
"""
Processes the TWI, along with any dependencies (like the slope and UCA)
Parameters
-----------
index : int/slice (optional)
Default: None - process all tiles in source directory. Otherwise,
... | def process_twi(self, index=None, do_edges=False, skip_uca_twi=False):
"""
Processes the TWI, along with any dependencies (like the slope and UCA)
Parameters
-----------
index : int/slice (optional)
Default: None - process all tiles in source directory. Otherwise,
... | [
"Processes",
"the",
"TWI",
"along",
"with",
"any",
"dependencies",
"(",
"like",
"the",
"slope",
"and",
"UCA",
")"
] | creare-com/pydem | python | https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/processing_manager.py#L614-L663 | [
"def",
"process_twi",
"(",
"self",
",",
"index",
"=",
"None",
",",
"do_edges",
"=",
"False",
",",
"skip_uca_twi",
"=",
"False",
")",
":",
"if",
"index",
"is",
"not",
"None",
":",
"elev_source_files",
"=",
"[",
"self",
".",
"elev_source_files",
"[",
"inde... | c2fc8d84cfb411df84f71a6dec9edc4b544f710a |
train | ProcessManager.process | This will completely process a directory of elevation tiles (as
supplied in the constructor). Both phases of the calculation, the
single tile and edge resolution phases are run.
Parameters
-----------
index : int/slice (optional)
Default None - processes all tiles in... | pydem/processing_manager.py | def process(self, index=None):
"""
This will completely process a directory of elevation tiles (as
supplied in the constructor). Both phases of the calculation, the
single tile and edge resolution phases are run.
Parameters
-----------
index : int/slice (optional... | def process(self, index=None):
"""
This will completely process a directory of elevation tiles (as
supplied in the constructor). Both phases of the calculation, the
single tile and edge resolution phases are run.
Parameters
-----------
index : int/slice (optional... | [
"This",
"will",
"completely",
"process",
"a",
"directory",
"of",
"elevation",
"tiles",
"(",
"as",
"supplied",
"in",
"the",
"constructor",
")",
".",
"Both",
"phases",
"of",
"the",
"calculation",
"the",
"single",
"tile",
"and",
"edge",
"resolution",
"phases",
... | creare-com/pydem | python | https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/processing_manager.py#L665-L709 | [
"def",
"process",
"(",
"self",
",",
"index",
"=",
"None",
")",
":",
"# Round 0 of twi processing, process the magnitude and directions of",
"# slopes",
"print",
"\"Starting slope calculation round\"",
"self",
".",
"process_twi",
"(",
"index",
",",
"do_edges",
"=",
"False"... | c2fc8d84cfb411df84f71a6dec9edc4b544f710a |
train | ProcessManager.calculate_twi | Calculates twi for supplied elevation file
Parameters
-----------
esfile : str
Path to elevation file to be processed
save_path: str
Root path to location where TWI will be saved. TWI will be saved in
a subdirectory 'twi'.
use_cache : bool (op... | pydem/processing_manager.py | def calculate_twi(self, esfile, save_path, use_cache=True, do_edges=False,
skip_uca_twi=False):
"""
Calculates twi for supplied elevation file
Parameters
-----------
esfile : str
Path to elevation file to be processed
save_path: str
... | def calculate_twi(self, esfile, save_path, use_cache=True, do_edges=False,
skip_uca_twi=False):
"""
Calculates twi for supplied elevation file
Parameters
-----------
esfile : str
Path to elevation file to be processed
save_path: str
... | [
"Calculates",
"twi",
"for",
"supplied",
"elevation",
"file"
] | creare-com/pydem | python | https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/processing_manager.py#L711-L860 | [
"def",
"calculate_twi",
"(",
"self",
",",
"esfile",
",",
"save_path",
",",
"use_cache",
"=",
"True",
",",
"do_edges",
"=",
"False",
",",
"skip_uca_twi",
"=",
"False",
")",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"os",
".",
"path",
".",
"joi... | c2fc8d84cfb411df84f71a6dec9edc4b544f710a |
train | ProcessManager.process_command | Processes the hillshading
Parameters
-----------
index : int/slice (optional)
Default: None - process all tiles in source directory. Otherwise,
will only process the index/indices of the files as listed in
self.elev_source_files | pydem/processing_manager.py | def process_command(self, command, save_name='custom', index=None):
"""
Processes the hillshading
Parameters
-----------
index : int/slice (optional)
Default: None - process all tiles in source directory. Otherwise,
will only process the index/indices of ... | def process_command(self, command, save_name='custom', index=None):
"""
Processes the hillshading
Parameters
-----------
index : int/slice (optional)
Default: None - process all tiles in source directory. Otherwise,
will only process the index/indices of ... | [
"Processes",
"the",
"hillshading"
] | creare-com/pydem | python | https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/processing_manager.py#L873-L932 | [
"def",
"process_command",
"(",
"self",
",",
"command",
",",
"save_name",
"=",
"'custom'",
",",
"index",
"=",
"None",
")",
":",
"if",
"index",
"is",
"not",
"None",
":",
"elev_source_files",
"=",
"[",
"self",
".",
"elev_source_files",
"[",
"index",
"]",
"]... | c2fc8d84cfb411df84f71a6dec9edc4b544f710a |
train | rename_files | Given a list of file paths for elevation files, this function will rename
those files to the format required by the pyDEM package.
This assumes a .tif extension.
Parameters
-----------
files : list
A list of strings of the paths to the elevation files that will be
renamed
name ... | pydem/utils.py | def rename_files(files, name=None):
"""
Given a list of file paths for elevation files, this function will rename
those files to the format required by the pyDEM package.
This assumes a .tif extension.
Parameters
-----------
files : list
A list of strings of the paths to the elevat... | def rename_files(files, name=None):
"""
Given a list of file paths for elevation files, this function will rename
those files to the format required by the pyDEM package.
This assumes a .tif extension.
Parameters
-----------
files : list
A list of strings of the paths to the elevat... | [
"Given",
"a",
"list",
"of",
"file",
"paths",
"for",
"elevation",
"files",
"this",
"function",
"will",
"rename",
"those",
"files",
"to",
"the",
"format",
"required",
"by",
"the",
"pyDEM",
"package",
"."
] | creare-com/pydem | python | https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/utils.py#L46-L74 | [
"def",
"rename_files",
"(",
"files",
",",
"name",
"=",
"None",
")",
":",
"for",
"fil",
"in",
"files",
":",
"elev_file",
"=",
"GdalReader",
"(",
"file_name",
"=",
"fil",
")",
"elev",
",",
"=",
"elev_file",
".",
"raster_layers",
"fn",
"=",
"get_fn",
"(",... | c2fc8d84cfb411df84f71a6dec9edc4b544f710a |
train | parse_fn | This parses the file name and returns the coordinates of the tile
Parameters
-----------
fn : str
Filename of a GEOTIFF
Returns
--------
coords = [LLC.lat, LLC.lon, URC.lat, URC.lon] | pydem/utils.py | def parse_fn(fn):
""" This parses the file name and returns the coordinates of the tile
Parameters
-----------
fn : str
Filename of a GEOTIFF
Returns
--------
coords = [LLC.lat, LLC.lon, URC.lat, URC.lon]
"""
try:
parts = os.path.splitext(os.path.split(fn)[-1])[0].r... | def parse_fn(fn):
""" This parses the file name and returns the coordinates of the tile
Parameters
-----------
fn : str
Filename of a GEOTIFF
Returns
--------
coords = [LLC.lat, LLC.lon, URC.lat, URC.lon]
"""
try:
parts = os.path.splitext(os.path.split(fn)[-1])[0].r... | [
"This",
"parses",
"the",
"file",
"name",
"and",
"returns",
"the",
"coordinates",
"of",
"the",
"tile"
] | creare-com/pydem | python | https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/utils.py#L77-L96 | [
"def",
"parse_fn",
"(",
"fn",
")",
":",
"try",
":",
"parts",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"os",
".",
"path",
".",
"split",
"(",
"fn",
")",
"[",
"-",
"1",
"]",
")",
"[",
"0",
"]",
".",
"replace",
"(",
"'o'",
",",
"'.'",
")",... | c2fc8d84cfb411df84f71a6dec9edc4b544f710a |
train | get_fn | Determines the standard filename for a given GeoTIFF Layer.
Parameters
-----------
elev : GdalReader.raster_layer
A raster layer from the GdalReader object.
name : str (optional)
An optional suffix to the filename.
Returns
-------
fn : str
The standard <filename>_<na... | pydem/utils.py | def get_fn(elev, name=None):
"""
Determines the standard filename for a given GeoTIFF Layer.
Parameters
-----------
elev : GdalReader.raster_layer
A raster layer from the GdalReader object.
name : str (optional)
An optional suffix to the filename.
Returns
-------
fn ... | def get_fn(elev, name=None):
"""
Determines the standard filename for a given GeoTIFF Layer.
Parameters
-----------
elev : GdalReader.raster_layer
A raster layer from the GdalReader object.
name : str (optional)
An optional suffix to the filename.
Returns
-------
fn ... | [
"Determines",
"the",
"standard",
"filename",
"for",
"a",
"given",
"GeoTIFF",
"Layer",
"."
] | creare-com/pydem | python | https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/utils.py#L99-L116 | [
"def",
"get_fn",
"(",
"elev",
",",
"name",
"=",
"None",
")",
":",
"gcs",
"=",
"elev",
".",
"grid_coordinates",
"coords",
"=",
"[",
"gcs",
".",
"LLC",
".",
"lat",
",",
"gcs",
".",
"LLC",
".",
"lon",
",",
"gcs",
".",
"URC",
".",
"lat",
",",
"gcs"... | c2fc8d84cfb411df84f71a6dec9edc4b544f710a |
train | get_fn_from_coords | Given a set of coordinates, returns the standard filename.
Parameters
-----------
coords : list
[LLC.lat, LLC.lon, URC.lat, URC.lon]
name : str (optional)
An optional suffix to the filename.
Returns
-------
fn : str
The standard <filename>_<name>.tif with suffix (if... | pydem/utils.py | def get_fn_from_coords(coords, name=None):
""" Given a set of coordinates, returns the standard filename.
Parameters
-----------
coords : list
[LLC.lat, LLC.lon, URC.lat, URC.lon]
name : str (optional)
An optional suffix to the filename.
Returns
-------
fn : str
... | def get_fn_from_coords(coords, name=None):
""" Given a set of coordinates, returns the standard filename.
Parameters
-----------
coords : list
[LLC.lat, LLC.lon, URC.lat, URC.lon]
name : str (optional)
An optional suffix to the filename.
Returns
-------
fn : str
... | [
"Given",
"a",
"set",
"of",
"coordinates",
"returns",
"the",
"standard",
"filename",
"."
] | creare-com/pydem | python | https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/utils.py#L119-L142 | [
"def",
"get_fn_from_coords",
"(",
"coords",
",",
"name",
"=",
"None",
")",
":",
"NS1",
"=",
"[",
"\"S\"",
",",
"\"N\"",
"]",
"[",
"coords",
"[",
"0",
"]",
">",
"0",
"]",
"EW1",
"=",
"[",
"\"W\"",
",",
"\"E\"",
"]",
"[",
"coords",
"[",
"1",
"]",... | c2fc8d84cfb411df84f71a6dec9edc4b544f710a |
train | mk_dx_dy_from_geotif_layer | Extracts the change in x and y coordinates from the geotiff file. Presently
only supports WGS-84 files. | pydem/utils.py | def mk_dx_dy_from_geotif_layer(geotif):
"""
Extracts the change in x and y coordinates from the geotiff file. Presently
only supports WGS-84 files.
"""
ELLIPSOID_MAP = {'WGS84': 'WGS-84'}
ellipsoid = ELLIPSOID_MAP[geotif.grid_coordinates.wkt]
d = distance(ellipsoid=ellipsoid)
dx = geotif... | def mk_dx_dy_from_geotif_layer(geotif):
"""
Extracts the change in x and y coordinates from the geotiff file. Presently
only supports WGS-84 files.
"""
ELLIPSOID_MAP = {'WGS84': 'WGS-84'}
ellipsoid = ELLIPSOID_MAP[geotif.grid_coordinates.wkt]
d = distance(ellipsoid=ellipsoid)
dx = geotif... | [
"Extracts",
"the",
"change",
"in",
"x",
"and",
"y",
"coordinates",
"from",
"the",
"geotiff",
"file",
".",
"Presently",
"only",
"supports",
"WGS",
"-",
"84",
"files",
"."
] | creare-com/pydem | python | https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/utils.py#L145-L161 | [
"def",
"mk_dx_dy_from_geotif_layer",
"(",
"geotif",
")",
":",
"ELLIPSOID_MAP",
"=",
"{",
"'WGS84'",
":",
"'WGS-84'",
"}",
"ellipsoid",
"=",
"ELLIPSOID_MAP",
"[",
"geotif",
".",
"grid_coordinates",
".",
"wkt",
"]",
"d",
"=",
"distance",
"(",
"ellipsoid",
"=",
... | c2fc8d84cfb411df84f71a6dec9edc4b544f710a |
train | mk_geotiff_obj | Creates a new geotiff file objects using the WGS84 coordinate system, saves
it to disk, and returns a handle to the python file object and driver
Parameters
------------
raster : array
Numpy array of the raster data to be added to the object
fn : str
Name of the geotiff file
ban... | pydem/utils.py | def mk_geotiff_obj(raster, fn, bands=1, gdal_data_type=gdal.GDT_Float32,
lat=[46, 45], lon=[-73, -72]):
"""
Creates a new geotiff file objects using the WGS84 coordinate system, saves
it to disk, and returns a handle to the python file object and driver
Parameters
------------
... | def mk_geotiff_obj(raster, fn, bands=1, gdal_data_type=gdal.GDT_Float32,
lat=[46, 45], lon=[-73, -72]):
"""
Creates a new geotiff file objects using the WGS84 coordinate system, saves
it to disk, and returns a handle to the python file object and driver
Parameters
------------
... | [
"Creates",
"a",
"new",
"geotiff",
"file",
"objects",
"using",
"the",
"WGS84",
"coordinate",
"system",
"saves",
"it",
"to",
"disk",
"and",
"returns",
"a",
"handle",
"to",
"the",
"python",
"file",
"object",
"and",
"driver"
] | creare-com/pydem | python | https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/utils.py#L164-L195 | [
"def",
"mk_geotiff_obj",
"(",
"raster",
",",
"fn",
",",
"bands",
"=",
"1",
",",
"gdal_data_type",
"=",
"gdal",
".",
"GDT_Float32",
",",
"lat",
"=",
"[",
"46",
",",
"45",
"]",
",",
"lon",
"=",
"[",
"-",
"73",
",",
"-",
"72",
"]",
")",
":",
"NNi"... | c2fc8d84cfb411df84f71a6dec9edc4b544f710a |
train | sortrows | Sorts array "a" by columns i
Parameters
------------
a : np.ndarray
array to be sorted
i : int (optional)
column to be sorted by, taken as 0 by default
index_out : bool (optional)
return the index I such that a(I) = sortrows(a,i). Default = False
recurse : bool (optional... | pydem/utils.py | def sortrows(a, i=0, index_out=False, recurse=True):
""" Sorts array "a" by columns i
Parameters
------------
a : np.ndarray
array to be sorted
i : int (optional)
column to be sorted by, taken as 0 by default
index_out : bool (optional)
return the index I such that a(I) ... | def sortrows(a, i=0, index_out=False, recurse=True):
""" Sorts array "a" by columns i
Parameters
------------
a : np.ndarray
array to be sorted
i : int (optional)
column to be sorted by, taken as 0 by default
index_out : bool (optional)
return the index I such that a(I) ... | [
"Sorts",
"array",
"a",
"by",
"columns",
"i"
] | creare-com/pydem | python | https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/utils.py#L198-L258 | [
"def",
"sortrows",
"(",
"a",
",",
"i",
"=",
"0",
",",
"index_out",
"=",
"False",
",",
"recurse",
"=",
"True",
")",
":",
"I",
"=",
"np",
".",
"argsort",
"(",
"a",
"[",
":",
",",
"i",
"]",
")",
"a",
"=",
"a",
"[",
"I",
",",
":",
"]",
"# We ... | c2fc8d84cfb411df84f71a6dec9edc4b544f710a |
train | get_adjacent_index | Find indices 2d-adjacent to those in I. Helper function for get_border*.
Parameters
----------
I : np.ndarray(dtype=int)
indices in the flattened region
shape : tuple(int, int)
region shape
size : int
region size (technically computable from shape)
Returns
-------
... | pydem/utils.py | def get_adjacent_index(I, shape, size):
"""
Find indices 2d-adjacent to those in I. Helper function for get_border*.
Parameters
----------
I : np.ndarray(dtype=int)
indices in the flattened region
shape : tuple(int, int)
region shape
size : int
region size (technical... | def get_adjacent_index(I, shape, size):
"""
Find indices 2d-adjacent to those in I. Helper function for get_border*.
Parameters
----------
I : np.ndarray(dtype=int)
indices in the flattened region
shape : tuple(int, int)
region shape
size : int
region size (technical... | [
"Find",
"indices",
"2d",
"-",
"adjacent",
"to",
"those",
"in",
"I",
".",
"Helper",
"function",
"for",
"get_border",
"*",
"."
] | creare-com/pydem | python | https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/utils.py#L260-L301 | [
"def",
"get_adjacent_index",
"(",
"I",
",",
"shape",
",",
"size",
")",
":",
"m",
",",
"n",
"=",
"shape",
"In",
"=",
"I",
"%",
"n",
"bL",
"=",
"In",
"!=",
"0",
"bR",
"=",
"In",
"!=",
"n",
"-",
"1",
"J",
"=",
"np",
".",
"concatenate",
"(",
"[... | c2fc8d84cfb411df84f71a6dec9edc4b544f710a |
train | get_border_index | Get flattened indices for the border of the region I.
Parameters
----------
I : np.ndarray(dtype=int)
indices in the flattened region.
size : int
region size (technically computable from shape argument)
shape : tuple(int, int)
region shape
Returns
-------
J : np... | pydem/utils.py | def get_border_index(I, shape, size):
"""
Get flattened indices for the border of the region I.
Parameters
----------
I : np.ndarray(dtype=int)
indices in the flattened region.
size : int
region size (technically computable from shape argument)
shape : tuple(int, int)
... | def get_border_index(I, shape, size):
"""
Get flattened indices for the border of the region I.
Parameters
----------
I : np.ndarray(dtype=int)
indices in the flattened region.
size : int
region size (technically computable from shape argument)
shape : tuple(int, int)
... | [
"Get",
"flattened",
"indices",
"for",
"the",
"border",
"of",
"the",
"region",
"I",
"."
] | creare-com/pydem | python | https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/utils.py#L303-L330 | [
"def",
"get_border_index",
"(",
"I",
",",
"shape",
",",
"size",
")",
":",
"J",
"=",
"get_adjacent_index",
"(",
"I",
",",
"shape",
",",
"size",
")",
"# instead of setdiff?",
"# border = np.zeros(size)",
"# border[J] = 1",
"# border[I] = 0",
"# J, = np.where(border)",
... | c2fc8d84cfb411df84f71a6dec9edc4b544f710a |
train | get_border_mask | Get border of the region as a boolean array mask.
Parameters
----------
region : np.ndarray(shape=(m, n), dtype=bool)
mask of the region
Returns
-------
border : np.ndarray(shape=(m, n), dtype=bool)
mask of the region border (not including region) | pydem/utils.py | def get_border_mask(region):
"""
Get border of the region as a boolean array mask.
Parameters
----------
region : np.ndarray(shape=(m, n), dtype=bool)
mask of the region
Returns
-------
border : np.ndarray(shape=(m, n), dtype=bool)
mask of the region border (not includi... | def get_border_mask(region):
"""
Get border of the region as a boolean array mask.
Parameters
----------
region : np.ndarray(shape=(m, n), dtype=bool)
mask of the region
Returns
-------
border : np.ndarray(shape=(m, n), dtype=bool)
mask of the region border (not includi... | [
"Get",
"border",
"of",
"the",
"region",
"as",
"a",
"boolean",
"array",
"mask",
"."
] | creare-com/pydem | python | https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/utils.py#L332-L360 | [
"def",
"get_border_mask",
"(",
"region",
")",
":",
"# common special case (for efficiency)",
"internal",
"=",
"region",
"[",
"1",
":",
"-",
"1",
",",
"1",
":",
"-",
"1",
"]",
"if",
"internal",
".",
"all",
"(",
")",
"and",
"internal",
".",
"any",
"(",
"... | c2fc8d84cfb411df84f71a6dec9edc4b544f710a |
train | get_distance | Compute within-region distances from the src pixels.
Parameters
----------
region : np.ndarray(shape=(m, n), dtype=bool)
mask of the region
src : np.ndarray(shape=(m, n), dtype=bool)
mask of the source pixels to compute distances from.
Returns
-------
d : np.ndarray(shape=(... | pydem/utils.py | def get_distance(region, src):
"""
Compute within-region distances from the src pixels.
Parameters
----------
region : np.ndarray(shape=(m, n), dtype=bool)
mask of the region
src : np.ndarray(shape=(m, n), dtype=bool)
mask of the source pixels to compute distances from.
Ret... | def get_distance(region, src):
"""
Compute within-region distances from the src pixels.
Parameters
----------
region : np.ndarray(shape=(m, n), dtype=bool)
mask of the region
src : np.ndarray(shape=(m, n), dtype=bool)
mask of the source pixels to compute distances from.
Ret... | [
"Compute",
"within",
"-",
"region",
"distances",
"from",
"the",
"src",
"pixels",
"."
] | creare-com/pydem | python | https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/utils.py#L364-L392 | [
"def",
"get_distance",
"(",
"region",
",",
"src",
")",
":",
"dmax",
"=",
"float",
"(",
"region",
".",
"size",
")",
"d",
"=",
"np",
".",
"full",
"(",
"region",
".",
"shape",
",",
"dmax",
")",
"d",
"[",
"src",
"]",
"=",
"0",
"for",
"n",
"in",
"... | c2fc8d84cfb411df84f71a6dec9edc4b544f710a |
train | grow_slice | Grow a slice object by 1 in each direction without overreaching the list.
Parameters
----------
slc: slice
slice object to grow
size: int
list length
Returns
-------
slc: slice
extended slice | pydem/utils.py | def grow_slice(slc, size):
"""
Grow a slice object by 1 in each direction without overreaching the list.
Parameters
----------
slc: slice
slice object to grow
size: int
list length
Returns
-------
slc: slice
extended slice
"""
return slice(max(0, s... | def grow_slice(slc, size):
"""
Grow a slice object by 1 in each direction without overreaching the list.
Parameters
----------
slc: slice
slice object to grow
size: int
list length
Returns
-------
slc: slice
extended slice
"""
return slice(max(0, s... | [
"Grow",
"a",
"slice",
"object",
"by",
"1",
"in",
"each",
"direction",
"without",
"overreaching",
"the",
"list",
"."
] | creare-com/pydem | python | https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/utils.py#L400-L418 | [
"def",
"grow_slice",
"(",
"slc",
",",
"size",
")",
":",
"return",
"slice",
"(",
"max",
"(",
"0",
",",
"slc",
".",
"start",
"-",
"1",
")",
",",
"min",
"(",
"size",
",",
"slc",
".",
"stop",
"+",
"1",
")",
")"
] | c2fc8d84cfb411df84f71a6dec9edc4b544f710a |
train | is_edge | Check if a 2d object is on the edge of the array.
Parameters
----------
obj : tuple(slice, slice)
Pair of slices (e.g. from scipy.ndimage.measurements.find_objects)
shape : tuple(int, int)
Array shape.
Returns
-------
b : boolean
True if the object touches any edge ... | pydem/utils.py | def is_edge(obj, shape):
"""
Check if a 2d object is on the edge of the array.
Parameters
----------
obj : tuple(slice, slice)
Pair of slices (e.g. from scipy.ndimage.measurements.find_objects)
shape : tuple(int, int)
Array shape.
Returns
-------
b : boolean
... | def is_edge(obj, shape):
"""
Check if a 2d object is on the edge of the array.
Parameters
----------
obj : tuple(slice, slice)
Pair of slices (e.g. from scipy.ndimage.measurements.find_objects)
shape : tuple(int, int)
Array shape.
Returns
-------
b : boolean
... | [
"Check",
"if",
"a",
"2d",
"object",
"is",
"on",
"the",
"edge",
"of",
"the",
"array",
"."
] | creare-com/pydem | python | https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/utils.py#L439-L460 | [
"def",
"is_edge",
"(",
"obj",
",",
"shape",
")",
":",
"if",
"obj",
"[",
"0",
"]",
".",
"start",
"==",
"0",
":",
"return",
"True",
"if",
"obj",
"[",
"1",
"]",
".",
"start",
"==",
"0",
":",
"return",
"True",
"if",
"obj",
"[",
"0",
"]",
".",
"... | c2fc8d84cfb411df84f71a6dec9edc4b544f710a |
train | find_centroid | Finds an approximate centroid for a region that is within the region.
Parameters
----------
region : np.ndarray(shape=(m, n), dtype='bool')
mask of the region.
Returns
-------
i, j : tuple(int, int)
2d index within the region nearest the center of mass. | pydem/utils.py | def find_centroid(region):
"""
Finds an approximate centroid for a region that is within the region.
Parameters
----------
region : np.ndarray(shape=(m, n), dtype='bool')
mask of the region.
Returns
-------
i, j : tuple(int, int)
2d index within the region nearest t... | def find_centroid(region):
"""
Finds an approximate centroid for a region that is within the region.
Parameters
----------
region : np.ndarray(shape=(m, n), dtype='bool')
mask of the region.
Returns
-------
i, j : tuple(int, int)
2d index within the region nearest t... | [
"Finds",
"an",
"approximate",
"centroid",
"for",
"a",
"region",
"that",
"is",
"within",
"the",
"region",
".",
"Parameters",
"----------",
"region",
":",
"np",
".",
"ndarray",
"(",
"shape",
"=",
"(",
"m",
"n",
")",
"dtype",
"=",
"bool",
")",
"mask",
"of... | creare-com/pydem | python | https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/utils.py#L462-L480 | [
"def",
"find_centroid",
"(",
"region",
")",
":",
"x",
",",
"y",
"=",
"center_of_mass",
"(",
"region",
")",
"w",
"=",
"np",
".",
"argwhere",
"(",
"region",
")",
"i",
",",
"j",
"=",
"w",
"[",
"np",
".",
"argmin",
"(",
"np",
".",
"linalg",
".",
"n... | c2fc8d84cfb411df84f71a6dec9edc4b544f710a |
train | WriteBuffer.clear | Resets the object at its initial (empty) state. | tornadis/write_buffer.py | def clear(self):
"""Resets the object at its initial (empty) state."""
self._deque.clear()
self._total_length = 0
self._has_view = False | def clear(self):
"""Resets the object at its initial (empty) state."""
self._deque.clear()
self._total_length = 0
self._has_view = False | [
"Resets",
"the",
"object",
"at",
"its",
"initial",
"(",
"empty",
")",
"state",
"."
] | thefab/tornadis | python | https://github.com/thefab/tornadis/blob/f9dc883e46eb5971b62eab38346319757e5f900f/tornadis/write_buffer.py#L39-L43 | [
"def",
"clear",
"(",
"self",
")",
":",
"self",
".",
"_deque",
".",
"clear",
"(",
")",
"self",
".",
"_total_length",
"=",
"0",
"self",
".",
"_has_view",
"=",
"False"
] | f9dc883e46eb5971b62eab38346319757e5f900f |
train | WriteBuffer._tobytes | Serializes the write buffer into a single string (bytes).
Returns:
a string (bytes) object. | tornadis/write_buffer.py | def _tobytes(self):
"""Serializes the write buffer into a single string (bytes).
Returns:
a string (bytes) object.
"""
if not self._has_view:
# fast path optimization
if len(self._deque) == 0:
return b""
elif len(self._dequ... | def _tobytes(self):
"""Serializes the write buffer into a single string (bytes).
Returns:
a string (bytes) object.
"""
if not self._has_view:
# fast path optimization
if len(self._deque) == 0:
return b""
elif len(self._dequ... | [
"Serializes",
"the",
"write",
"buffer",
"into",
"a",
"single",
"string",
"(",
"bytes",
")",
"."
] | thefab/tornadis | python | https://github.com/thefab/tornadis/blob/f9dc883e46eb5971b62eab38346319757e5f900f/tornadis/write_buffer.py#L54-L72 | [
"def",
"_tobytes",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_has_view",
":",
"# fast path optimization",
"if",
"len",
"(",
"self",
".",
"_deque",
")",
"==",
"0",
":",
"return",
"b\"\"",
"elif",
"len",
"(",
"self",
".",
"_deque",
")",
"==",
"... | f9dc883e46eb5971b62eab38346319757e5f900f |
train | WriteBuffer.pop_chunk | Pops a chunk of the given max size.
Optimized to avoid too much string copies.
Args:
chunk_max_size (int): max size of the returned chunk.
Returns:
string (bytes) with a size <= chunk_max_size. | tornadis/write_buffer.py | def pop_chunk(self, chunk_max_size):
"""Pops a chunk of the given max size.
Optimized to avoid too much string copies.
Args:
chunk_max_size (int): max size of the returned chunk.
Returns:
string (bytes) with a size <= chunk_max_size.
"""
if self... | def pop_chunk(self, chunk_max_size):
"""Pops a chunk of the given max size.
Optimized to avoid too much string copies.
Args:
chunk_max_size (int): max size of the returned chunk.
Returns:
string (bytes) with a size <= chunk_max_size.
"""
if self... | [
"Pops",
"a",
"chunk",
"of",
"the",
"given",
"max",
"size",
"."
] | thefab/tornadis | python | https://github.com/thefab/tornadis/blob/f9dc883e46eb5971b62eab38346319757e5f900f/tornadis/write_buffer.py#L134-L190 | [
"def",
"pop_chunk",
"(",
"self",
",",
"chunk_max_size",
")",
":",
"if",
"self",
".",
"_total_length",
"<",
"chunk_max_size",
":",
"# fastpath (the whole queue fit in a single chunk)",
"res",
"=",
"self",
".",
"_tobytes",
"(",
")",
"self",
".",
"clear",
"(",
")",... | f9dc883e46eb5971b62eab38346319757e5f900f |
train | PurePath.with_name | Return a new path with the file name changed. | tasks/_vendor/pathlib.py | def with_name(self, name):
"""Return a new path with the file name changed."""
if not self.name:
raise ValueError("%r has an empty name" % (self,))
return self._from_parsed_parts(self._drv, self._root,
self._parts[:-1] + [name]) | def with_name(self, name):
"""Return a new path with the file name changed."""
if not self.name:
raise ValueError("%r has an empty name" % (self,))
return self._from_parsed_parts(self._drv, self._root,
self._parts[:-1] + [name]) | [
"Return",
"a",
"new",
"path",
"with",
"the",
"file",
"name",
"changed",
"."
] | click-contrib/click-configfile | python | https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/tasks/_vendor/pathlib.py#L773-L778 | [
"def",
"with_name",
"(",
"self",
",",
"name",
")",
":",
"if",
"not",
"self",
".",
"name",
":",
"raise",
"ValueError",
"(",
"\"%r has an empty name\"",
"%",
"(",
"self",
",",
")",
")",
"return",
"self",
".",
"_from_parsed_parts",
"(",
"self",
".",
"_drv",... | a616204cb9944125fd5051556f27a7ccef611e22 |
train | PurePath.with_suffix | Return a new path with the file suffix changed (or added, if none). | tasks/_vendor/pathlib.py | def with_suffix(self, suffix):
"""Return a new path with the file suffix changed (or added, if none)."""
# XXX if suffix is None, should the current suffix be removed?
drv, root, parts = self._flavour.parse_parts((suffix,))
if drv or root or len(parts) != 1:
raise ValueError(... | def with_suffix(self, suffix):
"""Return a new path with the file suffix changed (or added, if none)."""
# XXX if suffix is None, should the current suffix be removed?
drv, root, parts = self._flavour.parse_parts((suffix,))
if drv or root or len(parts) != 1:
raise ValueError(... | [
"Return",
"a",
"new",
"path",
"with",
"the",
"file",
"suffix",
"changed",
"(",
"or",
"added",
"if",
"none",
")",
"."
] | click-contrib/click-configfile | python | https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/tasks/_vendor/pathlib.py#L780-L798 | [
"def",
"with_suffix",
"(",
"self",
",",
"suffix",
")",
":",
"# XXX if suffix is None, should the current suffix be removed?",
"drv",
",",
"root",
",",
"parts",
"=",
"self",
".",
"_flavour",
".",
"parse_parts",
"(",
"(",
"suffix",
",",
")",
")",
"if",
"drv",
"o... | a616204cb9944125fd5051556f27a7ccef611e22 |
train | Path._raw_open | Open the file pointed by this path and return a file descriptor,
as os.open() does. | tasks/_vendor/pathlib.py | def _raw_open(self, flags, mode=0o777):
"""
Open the file pointed by this path and return a file descriptor,
as os.open() does.
"""
return self._accessor.open(self, flags, mode) | def _raw_open(self, flags, mode=0o777):
"""
Open the file pointed by this path and return a file descriptor,
as os.open() does.
"""
return self._accessor.open(self, flags, mode) | [
"Open",
"the",
"file",
"pointed",
"by",
"this",
"path",
"and",
"return",
"a",
"file",
"descriptor",
"as",
"os",
".",
"open",
"()",
"does",
"."
] | click-contrib/click-configfile | python | https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/tasks/_vendor/pathlib.py#L962-L967 | [
"def",
"_raw_open",
"(",
"self",
",",
"flags",
",",
"mode",
"=",
"0o777",
")",
":",
"return",
"self",
".",
"_accessor",
".",
"open",
"(",
"self",
",",
"flags",
",",
"mode",
")"
] | a616204cb9944125fd5051556f27a7ccef611e22 |
train | Path.iterdir | Iterate over the files in this directory. Does not yield any
result for the special paths '.' and '..'. | tasks/_vendor/pathlib.py | def iterdir(self):
"""Iterate over the files in this directory. Does not yield any
result for the special paths '.' and '..'.
"""
for name in self._accessor.listdir(self):
if name in ('.', '..'):
# Yielding a path object for these makes little sense
... | def iterdir(self):
"""Iterate over the files in this directory. Does not yield any
result for the special paths '.' and '..'.
"""
for name in self._accessor.listdir(self):
if name in ('.', '..'):
# Yielding a path object for these makes little sense
... | [
"Iterate",
"over",
"the",
"files",
"in",
"this",
"directory",
".",
"Does",
"not",
"yield",
"any",
"result",
"for",
"the",
"special",
"paths",
".",
"and",
"..",
"."
] | click-contrib/click-configfile | python | https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/tasks/_vendor/pathlib.py#L978-L986 | [
"def",
"iterdir",
"(",
"self",
")",
":",
"for",
"name",
"in",
"self",
".",
"_accessor",
".",
"listdir",
"(",
"self",
")",
":",
"if",
"name",
"in",
"(",
"'.'",
",",
"'..'",
")",
":",
"# Yielding a path object for these makes little sense",
"continue",
"yield"... | a616204cb9944125fd5051556f27a7ccef611e22 |
train | Path.absolute | Return an absolute version of this path. This function works
even if the path doesn't point to anything.
No normalization is done, i.e. all '.' and '..' will be kept along.
Use resolve() to get the canonical path to a file. | tasks/_vendor/pathlib.py | def absolute(self):
"""Return an absolute version of this path. This function works
even if the path doesn't point to anything.
No normalization is done, i.e. all '.' and '..' will be kept along.
Use resolve() to get the canonical path to a file.
"""
# XXX untested yet!... | def absolute(self):
"""Return an absolute version of this path. This function works
even if the path doesn't point to anything.
No normalization is done, i.e. all '.' and '..' will be kept along.
Use resolve() to get the canonical path to a file.
"""
# XXX untested yet!... | [
"Return",
"an",
"absolute",
"version",
"of",
"this",
"path",
".",
"This",
"function",
"works",
"even",
"if",
"the",
"path",
"doesn",
"t",
"point",
"to",
"anything",
"."
] | click-contrib/click-configfile | python | https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/tasks/_vendor/pathlib.py#L1012-L1026 | [
"def",
"absolute",
"(",
"self",
")",
":",
"# XXX untested yet!",
"if",
"self",
".",
"is_absolute",
"(",
")",
":",
"return",
"self",
"# FIXME this must defer to the specific flavour (and, under Windows,",
"# use nt._getfullpathname())",
"obj",
"=",
"self",
".",
"_from_part... | a616204cb9944125fd5051556f27a7ccef611e22 |
train | Path.resolve | Make the path absolute, resolving all symlinks on the way and also
normalizing it (for example turning slashes into backslashes under
Windows). | tasks/_vendor/pathlib.py | def resolve(self):
"""
Make the path absolute, resolving all symlinks on the way and also
normalizing it (for example turning slashes into backslashes under
Windows).
"""
s = self._flavour.resolve(self)
if s is None:
# No symlink resolution => for cons... | def resolve(self):
"""
Make the path absolute, resolving all symlinks on the way and also
normalizing it (for example turning slashes into backslashes under
Windows).
"""
s = self._flavour.resolve(self)
if s is None:
# No symlink resolution => for cons... | [
"Make",
"the",
"path",
"absolute",
"resolving",
"all",
"symlinks",
"on",
"the",
"way",
"and",
"also",
"normalizing",
"it",
"(",
"for",
"example",
"turning",
"slashes",
"into",
"backslashes",
"under",
"Windows",
")",
"."
] | click-contrib/click-configfile | python | https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/tasks/_vendor/pathlib.py#L1028-L1044 | [
"def",
"resolve",
"(",
"self",
")",
":",
"s",
"=",
"self",
".",
"_flavour",
".",
"resolve",
"(",
"self",
")",
"if",
"s",
"is",
"None",
":",
"# No symlink resolution => for consistency, raise an error if",
"# the path doesn't exist or is forbidden",
"self",
".",
"sta... | a616204cb9944125fd5051556f27a7ccef611e22 |
train | Path.open | Open the file pointed by this path and return a file object, as
the built-in open() function does. | tasks/_vendor/pathlib.py | def open(self, mode='r', buffering=-1, encoding=None,
errors=None, newline=None):
"""
Open the file pointed by this path and return a file object, as
the built-in open() function does.
"""
if sys.version_info >= (3, 3):
return io.open(str(self), mode, buf... | def open(self, mode='r', buffering=-1, encoding=None,
errors=None, newline=None):
"""
Open the file pointed by this path and return a file object, as
the built-in open() function does.
"""
if sys.version_info >= (3, 3):
return io.open(str(self), mode, buf... | [
"Open",
"the",
"file",
"pointed",
"by",
"this",
"path",
"and",
"return",
"a",
"file",
"object",
"as",
"the",
"built",
"-",
"in",
"open",
"()",
"function",
"does",
"."
] | click-contrib/click-configfile | python | https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/tasks/_vendor/pathlib.py#L1067-L1077 | [
"def",
"open",
"(",
"self",
",",
"mode",
"=",
"'r'",
",",
"buffering",
"=",
"-",
"1",
",",
"encoding",
"=",
"None",
",",
"errors",
"=",
"None",
",",
"newline",
"=",
"None",
")",
":",
"if",
"sys",
".",
"version_info",
">=",
"(",
"3",
",",
"3",
"... | a616204cb9944125fd5051556f27a7ccef611e22 |
train | Path.replace | Rename this path to the given path, clobbering the existing
destination if it exists. | tasks/_vendor/pathlib.py | def replace(self, target):
"""
Rename this path to the given path, clobbering the existing
destination if it exists.
"""
if sys.version_info < (3, 3):
raise NotImplementedError("replace() is only available "
"with Python 3.3 and l... | def replace(self, target):
"""
Rename this path to the given path, clobbering the existing
destination if it exists.
"""
if sys.version_info < (3, 3):
raise NotImplementedError("replace() is only available "
"with Python 3.3 and l... | [
"Rename",
"this",
"path",
"to",
"the",
"given",
"path",
"clobbering",
"the",
"existing",
"destination",
"if",
"it",
"exists",
"."
] | click-contrib/click-configfile | python | https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/tasks/_vendor/pathlib.py#L1152-L1160 | [
"def",
"replace",
"(",
"self",
",",
"target",
")",
":",
"if",
"sys",
".",
"version_info",
"<",
"(",
"3",
",",
"3",
")",
":",
"raise",
"NotImplementedError",
"(",
"\"replace() is only available \"",
"\"with Python 3.3 and later\"",
")",
"self",
".",
"_accessor",
... | a616204cb9944125fd5051556f27a7ccef611e22 |
train | Path.symlink_to | Make this path a symlink pointing to the given path.
Note the order of arguments (self, target) is the reverse of os.symlink's. | tasks/_vendor/pathlib.py | def symlink_to(self, target, target_is_directory=False):
"""
Make this path a symlink pointing to the given path.
Note the order of arguments (self, target) is the reverse of os.symlink's.
"""
self._accessor.symlink(target, self, target_is_directory) | def symlink_to(self, target, target_is_directory=False):
"""
Make this path a symlink pointing to the given path.
Note the order of arguments (self, target) is the reverse of os.symlink's.
"""
self._accessor.symlink(target, self, target_is_directory) | [
"Make",
"this",
"path",
"a",
"symlink",
"pointing",
"to",
"the",
"given",
"path",
".",
"Note",
"the",
"order",
"of",
"arguments",
"(",
"self",
"target",
")",
"is",
"the",
"reverse",
"of",
"os",
".",
"symlink",
"s",
"."
] | click-contrib/click-configfile | python | https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/tasks/_vendor/pathlib.py#L1162-L1167 | [
"def",
"symlink_to",
"(",
"self",
",",
"target",
",",
"target_is_directory",
"=",
"False",
")",
":",
"self",
".",
"_accessor",
".",
"symlink",
"(",
"target",
",",
"self",
",",
"target_is_directory",
")"
] | a616204cb9944125fd5051556f27a7ccef611e22 |
train | Path.is_symlink | Whether this path is a symbolic link. | tasks/_vendor/pathlib.py | def is_symlink(self):
"""
Whether this path is a symbolic link.
"""
try:
return S_ISLNK(self.lstat().st_mode)
except OSError as e:
if e.errno != ENOENT:
raise
# Path doesn't exist
return False | def is_symlink(self):
"""
Whether this path is a symbolic link.
"""
try:
return S_ISLNK(self.lstat().st_mode)
except OSError as e:
if e.errno != ENOENT:
raise
# Path doesn't exist
return False | [
"Whether",
"this",
"path",
"is",
"a",
"symbolic",
"link",
"."
] | click-contrib/click-configfile | python | https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/tasks/_vendor/pathlib.py#L1210-L1220 | [
"def",
"is_symlink",
"(",
"self",
")",
":",
"try",
":",
"return",
"S_ISLNK",
"(",
"self",
".",
"lstat",
"(",
")",
".",
"st_mode",
")",
"except",
"OSError",
"as",
"e",
":",
"if",
"e",
".",
"errno",
"!=",
"ENOENT",
":",
"raise",
"# Path doesn't exist",
... | a616204cb9944125fd5051556f27a7ccef611e22 |
train | Path.is_block_device | Whether this path is a block device. | tasks/_vendor/pathlib.py | def is_block_device(self):
"""
Whether this path is a block device.
"""
try:
return S_ISBLK(self.stat().st_mode)
except OSError as e:
if e.errno != ENOENT:
raise
# Path doesn't exist or is a broken symlink
# (see htt... | def is_block_device(self):
"""
Whether this path is a block device.
"""
try:
return S_ISBLK(self.stat().st_mode)
except OSError as e:
if e.errno != ENOENT:
raise
# Path doesn't exist or is a broken symlink
# (see htt... | [
"Whether",
"this",
"path",
"is",
"a",
"block",
"device",
"."
] | click-contrib/click-configfile | python | https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/tasks/_vendor/pathlib.py#L1222-L1233 | [
"def",
"is_block_device",
"(",
"self",
")",
":",
"try",
":",
"return",
"S_ISBLK",
"(",
"self",
".",
"stat",
"(",
")",
".",
"st_mode",
")",
"except",
"OSError",
"as",
"e",
":",
"if",
"e",
".",
"errno",
"!=",
"ENOENT",
":",
"raise",
"# Path doesn't exist... | a616204cb9944125fd5051556f27a7ccef611e22 |
train | Path.is_char_device | Whether this path is a character device. | tasks/_vendor/pathlib.py | def is_char_device(self):
"""
Whether this path is a character device.
"""
try:
return S_ISCHR(self.stat().st_mode)
except OSError as e:
if e.errno != ENOENT:
raise
# Path doesn't exist or is a broken symlink
# (see ... | def is_char_device(self):
"""
Whether this path is a character device.
"""
try:
return S_ISCHR(self.stat().st_mode)
except OSError as e:
if e.errno != ENOENT:
raise
# Path doesn't exist or is a broken symlink
# (see ... | [
"Whether",
"this",
"path",
"is",
"a",
"character",
"device",
"."
] | click-contrib/click-configfile | python | https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/tasks/_vendor/pathlib.py#L1235-L1246 | [
"def",
"is_char_device",
"(",
"self",
")",
":",
"try",
":",
"return",
"S_ISCHR",
"(",
"self",
".",
"stat",
"(",
")",
".",
"st_mode",
")",
"except",
"OSError",
"as",
"e",
":",
"if",
"e",
".",
"errno",
"!=",
"ENOENT",
":",
"raise",
"# Path doesn't exist ... | a616204cb9944125fd5051556f27a7ccef611e22 |
train | grid_coords_from_corners | Points are the outer edges of the UL and LR pixels. Size is rows, columns.
GC projection type is taken from Points. | pydem/reader/my_types.py | def grid_coords_from_corners(upper_left_corner, lower_right_corner, size):
''' Points are the outer edges of the UL and LR pixels. Size is rows, columns.
GC projection type is taken from Points. '''
assert upper_left_corner.wkt == lower_right_corner.wkt
geotransform = np.array([upper_left_corner.lon, -(... | def grid_coords_from_corners(upper_left_corner, lower_right_corner, size):
''' Points are the outer edges of the UL and LR pixels. Size is rows, columns.
GC projection type is taken from Points. '''
assert upper_left_corner.wkt == lower_right_corner.wkt
geotransform = np.array([upper_left_corner.lon, -(... | [
"Points",
"are",
"the",
"outer",
"edges",
"of",
"the",
"UL",
"and",
"LR",
"pixels",
".",
"Size",
"is",
"rows",
"columns",
".",
"GC",
"projection",
"type",
"is",
"taken",
"from",
"Points",
"."
] | creare-com/pydem | python | https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/reader/my_types.py#L150-L159 | [
"def",
"grid_coords_from_corners",
"(",
"upper_left_corner",
",",
"lower_right_corner",
",",
"size",
")",
":",
"assert",
"upper_left_corner",
".",
"wkt",
"==",
"lower_right_corner",
".",
"wkt",
"geotransform",
"=",
"np",
".",
"array",
"(",
"[",
"upper_left_corner",
... | c2fc8d84cfb411df84f71a6dec9edc4b544f710a |
train | GridCoordinates.intersects | returns True if the GC's overlap. | pydem/reader/my_types.py | def intersects(self, other_grid_coordinates):
""" returns True if the GC's overlap. """
ogc = other_grid_coordinates # alias
# for explanation: http://stackoverflow.com/questions/306316/determine-if-two-rectangles-overlap-each-other
# Note the flipped y-coord in this coord system.
... | def intersects(self, other_grid_coordinates):
""" returns True if the GC's overlap. """
ogc = other_grid_coordinates # alias
# for explanation: http://stackoverflow.com/questions/306316/determine-if-two-rectangles-overlap-each-other
# Note the flipped y-coord in this coord system.
... | [
"returns",
"True",
"if",
"the",
"GC",
"s",
"overlap",
"."
] | creare-com/pydem | python | https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/reader/my_types.py#L191-L201 | [
"def",
"intersects",
"(",
"self",
",",
"other_grid_coordinates",
")",
":",
"ogc",
"=",
"other_grid_coordinates",
"# alias",
"# for explanation: http://stackoverflow.com/questions/306316/determine-if-two-rectangles-overlap-each-other",
"# Note the flipped y-coord in this coord system.",
"... | c2fc8d84cfb411df84f71a6dec9edc4b544f710a |
train | GridCoordinates.unique_str | A string that (ideally) uniquely represents this GC object. This
helps with naming files for caching. 'Unique' is defined as 'If
GC1 != GC2, then GC1.unique_str() != GC2.unique_str()'; conversely,
'If GC1 == GC2, then GC1.unique_str() == GC2.unique_str()'.
The string should be filename-... | pydem/reader/my_types.py | def unique_str(self):
""" A string that (ideally) uniquely represents this GC object. This
helps with naming files for caching. 'Unique' is defined as 'If
GC1 != GC2, then GC1.unique_str() != GC2.unique_str()'; conversely,
'If GC1 == GC2, then GC1.unique_str() == GC2.unique_str()'.
... | def unique_str(self):
""" A string that (ideally) uniquely represents this GC object. This
helps with naming files for caching. 'Unique' is defined as 'If
GC1 != GC2, then GC1.unique_str() != GC2.unique_str()'; conversely,
'If GC1 == GC2, then GC1.unique_str() == GC2.unique_str()'.
... | [
"A",
"string",
"that",
"(",
"ideally",
")",
"uniquely",
"represents",
"this",
"GC",
"object",
".",
"This",
"helps",
"with",
"naming",
"files",
"for",
"caching",
".",
"Unique",
"is",
"defined",
"as",
"If",
"GC1",
"!",
"=",
"GC2",
"then",
"GC1",
".",
"un... | creare-com/pydem | python | https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/reader/my_types.py#L205-L227 | [
"def",
"unique_str",
"(",
"self",
")",
":",
"unique_str",
"=",
"\"_\"",
".",
"join",
"(",
"[",
"\"%.3f\"",
"%",
"f",
"for",
"f",
"in",
"self",
".",
"geotransform",
"]",
"+",
"[",
"\"%d\"",
"%",
"d",
"for",
"d",
"in",
"self",
".",
"x_size",
",",
"... | c2fc8d84cfb411df84f71a6dec9edc4b544f710a |
train | GridCoordinates._get_x_axis | See http://www.gdal.org/gdal_datamodel.html for details. | pydem/reader/my_types.py | def _get_x_axis(self):
"""See http://www.gdal.org/gdal_datamodel.html for details."""
# 0,0 is top/left top top/left pixel. Actual x/y coord of that pixel are (.5,.5).
x_centers = np.linspace(.5, self.x_size - .5, self.x_size)
y_centers = x_centers * 0
return (self.geotransform[0... | def _get_x_axis(self):
"""See http://www.gdal.org/gdal_datamodel.html for details."""
# 0,0 is top/left top top/left pixel. Actual x/y coord of that pixel are (.5,.5).
x_centers = np.linspace(.5, self.x_size - .5, self.x_size)
y_centers = x_centers * 0
return (self.geotransform[0... | [
"See",
"http",
":",
"//",
"www",
".",
"gdal",
".",
"org",
"/",
"gdal_datamodel",
".",
"html",
"for",
"details",
"."
] | creare-com/pydem | python | https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/reader/my_types.py#L244-L251 | [
"def",
"_get_x_axis",
"(",
"self",
")",
":",
"# 0,0 is top/left top top/left pixel. Actual x/y coord of that pixel are (.5,.5).",
"x_centers",
"=",
"np",
".",
"linspace",
"(",
".5",
",",
"self",
".",
"x_size",
"-",
".5",
",",
"self",
".",
"x_size",
")",
"y_centers",... | c2fc8d84cfb411df84f71a6dec9edc4b544f710a |
train | GridCoordinates._get_y_axis | See http://www.gdal.org/gdal_datamodel.html for details. | pydem/reader/my_types.py | def _get_y_axis(self):
"""See http://www.gdal.org/gdal_datamodel.html for details."""
# 0,0 is top/left top top/left pixel. Actual x/y coord of that pixel are (.5,.5).
y_centers = np.linspace(.5, self.y_size - .5, self.y_size)
x_centers = y_centers * 0
return (self.geotransform[3... | def _get_y_axis(self):
"""See http://www.gdal.org/gdal_datamodel.html for details."""
# 0,0 is top/left top top/left pixel. Actual x/y coord of that pixel are (.5,.5).
y_centers = np.linspace(.5, self.y_size - .5, self.y_size)
x_centers = y_centers * 0
return (self.geotransform[3... | [
"See",
"http",
":",
"//",
"www",
".",
"gdal",
".",
"org",
"/",
"gdal_datamodel",
".",
"html",
"for",
"details",
"."
] | creare-com/pydem | python | https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/reader/my_types.py#L254-L261 | [
"def",
"_get_y_axis",
"(",
"self",
")",
":",
"# 0,0 is top/left top top/left pixel. Actual x/y coord of that pixel are (.5,.5).",
"y_centers",
"=",
"np",
".",
"linspace",
"(",
".5",
",",
"self",
".",
"y_size",
"-",
".5",
",",
"self",
".",
"y_size",
")",
"x_centers",... | c2fc8d84cfb411df84f71a6dec9edc4b544f710a |
train | GridCoordinates.raster_to_projection_coords | Use pixel centers when appropriate.
See documentation for the GDAL function GetGeoTransform for details. | pydem/reader/my_types.py | def raster_to_projection_coords(self, pixel_x, pixel_y):
""" Use pixel centers when appropriate.
See documentation for the GDAL function GetGeoTransform for details. """
h_px_py = np.array([1, pixel_x, pixel_y])
gt = np.array([[1, 0, 0], self.geotransform[0:3], self.geotransform[3:6]])
... | def raster_to_projection_coords(self, pixel_x, pixel_y):
""" Use pixel centers when appropriate.
See documentation for the GDAL function GetGeoTransform for details. """
h_px_py = np.array([1, pixel_x, pixel_y])
gt = np.array([[1, 0, 0], self.geotransform[0:3], self.geotransform[3:6]])
... | [
"Use",
"pixel",
"centers",
"when",
"appropriate",
".",
"See",
"documentation",
"for",
"the",
"GDAL",
"function",
"GetGeoTransform",
"for",
"details",
"."
] | creare-com/pydem | python | https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/reader/my_types.py#L265-L271 | [
"def",
"raster_to_projection_coords",
"(",
"self",
",",
"pixel_x",
",",
"pixel_y",
")",
":",
"h_px_py",
"=",
"np",
".",
"array",
"(",
"[",
"1",
",",
"pixel_x",
",",
"pixel_y",
"]",
")",
"gt",
"=",
"np",
".",
"array",
"(",
"[",
"[",
"1",
",",
"0",
... | c2fc8d84cfb411df84f71a6dec9edc4b544f710a |
train | GridCoordinates.projection_to_raster_coords | Returns pixel centers.
See documentation for the GDAL function GetGeoTransform for details. | pydem/reader/my_types.py | def projection_to_raster_coords(self, lat, lon):
""" Returns pixel centers.
See documentation for the GDAL function GetGeoTransform for details. """
r_px_py = np.array([1, lon, lat])
tg = inv(np.array([[1, 0, 0], self.geotransform[0:3], self.geotransform[3:6]]))
return np.inner(t... | def projection_to_raster_coords(self, lat, lon):
""" Returns pixel centers.
See documentation for the GDAL function GetGeoTransform for details. """
r_px_py = np.array([1, lon, lat])
tg = inv(np.array([[1, 0, 0], self.geotransform[0:3], self.geotransform[3:6]]))
return np.inner(t... | [
"Returns",
"pixel",
"centers",
".",
"See",
"documentation",
"for",
"the",
"GDAL",
"function",
"GetGeoTransform",
"for",
"details",
"."
] | creare-com/pydem | python | https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/reader/my_types.py#L273-L278 | [
"def",
"projection_to_raster_coords",
"(",
"self",
",",
"lat",
",",
"lon",
")",
":",
"r_px_py",
"=",
"np",
".",
"array",
"(",
"[",
"1",
",",
"lon",
",",
"lat",
"]",
")",
"tg",
"=",
"inv",
"(",
"np",
".",
"array",
"(",
"[",
"[",
"1",
",",
"0",
... | c2fc8d84cfb411df84f71a6dec9edc4b544f710a |
train | AbstractDataLayer.reproject_to_grid_coordinates | Reprojects data in this layer to match that in the GridCoordinates
object. | pydem/reader/my_types.py | def reproject_to_grid_coordinates(self, grid_coordinates, interp=gdalconst.GRA_NearestNeighbour):
""" Reprojects data in this layer to match that in the GridCoordinates
object. """
source_dataset = self.grid_coordinates._as_gdal_dataset()
dest_dataset = grid_coordinates._as_gdal_dataset(... | def reproject_to_grid_coordinates(self, grid_coordinates, interp=gdalconst.GRA_NearestNeighbour):
""" Reprojects data in this layer to match that in the GridCoordinates
object. """
source_dataset = self.grid_coordinates._as_gdal_dataset()
dest_dataset = grid_coordinates._as_gdal_dataset(... | [
"Reprojects",
"data",
"in",
"this",
"layer",
"to",
"match",
"that",
"in",
"the",
"GridCoordinates",
"object",
"."
] | creare-com/pydem | python | https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/reader/my_types.py#L351-L368 | [
"def",
"reproject_to_grid_coordinates",
"(",
"self",
",",
"grid_coordinates",
",",
"interp",
"=",
"gdalconst",
".",
"GRA_NearestNeighbour",
")",
":",
"source_dataset",
"=",
"self",
".",
"grid_coordinates",
".",
"_as_gdal_dataset",
"(",
")",
"dest_dataset",
"=",
"gri... | c2fc8d84cfb411df84f71a6dec9edc4b544f710a |
train | AbstractDataLayer.inpaint | Replace masked-out elements in an array using an iterative image inpainting algorithm. | pydem/reader/my_types.py | def inpaint(self):
""" Replace masked-out elements in an array using an iterative image inpainting algorithm. """
import inpaint
filled = inpaint.replace_nans(np.ma.filled(self.raster_data, np.NAN).astype(np.float32), 3, 0.01, 2)
self.raster_data = np.ma.masked_invalid(filled) | def inpaint(self):
""" Replace masked-out elements in an array using an iterative image inpainting algorithm. """
import inpaint
filled = inpaint.replace_nans(np.ma.filled(self.raster_data, np.NAN).astype(np.float32), 3, 0.01, 2)
self.raster_data = np.ma.masked_invalid(filled) | [
"Replace",
"masked",
"-",
"out",
"elements",
"in",
"an",
"array",
"using",
"an",
"iterative",
"image",
"inpainting",
"algorithm",
"."
] | creare-com/pydem | python | https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/reader/my_types.py#L379-L384 | [
"def",
"inpaint",
"(",
"self",
")",
":",
"import",
"inpaint",
"filled",
"=",
"inpaint",
".",
"replace_nans",
"(",
"np",
".",
"ma",
".",
"filled",
"(",
"self",
".",
"raster_data",
",",
"np",
".",
"NAN",
")",
".",
"astype",
"(",
"np",
".",
"float32",
... | c2fc8d84cfb411df84f71a6dec9edc4b544f710a |
train | AbstractRasterDataLayer.interp_value | Lookup a pixel value in the raster data, performing linear interpolation
if necessary. Indexed ==> nearest neighbor (*fast*). | pydem/reader/my_types.py | def interp_value(self, lat, lon, indexed=False):
""" Lookup a pixel value in the raster data, performing linear interpolation
if necessary. Indexed ==> nearest neighbor (*fast*). """
(px, py) = self.grid_coordinates.projection_to_raster_coords(lat, lon)
if indexed:
return sel... | def interp_value(self, lat, lon, indexed=False):
""" Lookup a pixel value in the raster data, performing linear interpolation
if necessary. Indexed ==> nearest neighbor (*fast*). """
(px, py) = self.grid_coordinates.projection_to_raster_coords(lat, lon)
if indexed:
return sel... | [
"Lookup",
"a",
"pixel",
"value",
"in",
"the",
"raster",
"data",
"performing",
"linear",
"interpolation",
"if",
"necessary",
".",
"Indexed",
"==",
">",
"nearest",
"neighbor",
"(",
"*",
"fast",
"*",
")",
"."
] | creare-com/pydem | python | https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/reader/my_types.py#L445-L457 | [
"def",
"interp_value",
"(",
"self",
",",
"lat",
",",
"lon",
",",
"indexed",
"=",
"False",
")",
":",
"(",
"px",
",",
"py",
")",
"=",
"self",
".",
"grid_coordinates",
".",
"projection_to_raster_coords",
"(",
"lat",
",",
"lon",
")",
"if",
"indexed",
":",
... | c2fc8d84cfb411df84f71a6dec9edc4b544f710a |
train | ClientPool.get_connected_client | Gets a connected Client object.
If max_size is reached, this method will block until a new client
object is available.
Returns:
A Future object with connected Client instance as a result
(or ClientError if there was a connection problem) | tornadis/pool.py | def get_connected_client(self):
"""Gets a connected Client object.
If max_size is reached, this method will block until a new client
object is available.
Returns:
A Future object with connected Client instance as a result
(or ClientError if there was a conne... | def get_connected_client(self):
"""Gets a connected Client object.
If max_size is reached, this method will block until a new client
object is available.
Returns:
A Future object with connected Client instance as a result
(or ClientError if there was a conne... | [
"Gets",
"a",
"connected",
"Client",
"object",
"."
] | thefab/tornadis | python | https://github.com/thefab/tornadis/blob/f9dc883e46eb5971b62eab38346319757e5f900f/tornadis/pool.py#L75-L95 | [
"def",
"get_connected_client",
"(",
"self",
")",
":",
"if",
"self",
".",
"__sem",
"is",
"not",
"None",
":",
"yield",
"self",
".",
"__sem",
".",
"acquire",
"(",
")",
"client",
"=",
"None",
"newly_created",
",",
"client",
"=",
"self",
".",
"_get_client_fro... | f9dc883e46eb5971b62eab38346319757e5f900f |
train | ClientPool.get_client_nowait | Gets a Client object (not necessary connected).
If max_size is reached, this method will return None (and won't block).
Returns:
A Client instance (not necessary connected) as result (or None). | tornadis/pool.py | def get_client_nowait(self):
"""Gets a Client object (not necessary connected).
If max_size is reached, this method will return None (and won't block).
Returns:
A Client instance (not necessary connected) as result (or None).
"""
if self.__sem is not None:
... | def get_client_nowait(self):
"""Gets a Client object (not necessary connected).
If max_size is reached, this method will return None (and won't block).
Returns:
A Client instance (not necessary connected) as result (or None).
"""
if self.__sem is not None:
... | [
"Gets",
"a",
"Client",
"object",
"(",
"not",
"necessary",
"connected",
")",
"."
] | thefab/tornadis | python | https://github.com/thefab/tornadis/blob/f9dc883e46eb5971b62eab38346319757e5f900f/tornadis/pool.py#L97-L110 | [
"def",
"get_client_nowait",
"(",
"self",
")",
":",
"if",
"self",
".",
"__sem",
"is",
"not",
"None",
":",
"if",
"self",
".",
"__sem",
".",
"_value",
"==",
"0",
":",
"return",
"None",
"self",
".",
"__sem",
".",
"acquire",
"(",
")",
"_",
",",
"client"... | f9dc883e46eb5971b62eab38346319757e5f900f |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.