Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

t.rast.series: Add 'file_limit' option #2429

Merged
merged 3 commits into from
Aug 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions temporal/t.rast.series/t.rast.series.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,18 @@ <h2>DESCRIPTION</h2>
<em>t.rast.series</em> is a simple wrapper for the raster module
<b>r.series</b>. It supports a subset of the aggregation methods of
<b>r.series</b>.

<h2>NOTES</h2>

To avoid problems with too many open files, by default, the maximum
number of open files is set to 1000. If the number of input raster
files exceeds this number, the <b>-z</b> flag will be invoked. Because this
will slow down processing, the user can set a higher limit with the
<b>file_limit</b> parameter. Note that <b>file_limit</b> limit should not exceed the
user-specific limit on open files set by your operating system. See the
<a
href="https://grasswiki.osgeo.org/wiki/Large_raster_data_processing#Number_of_open_files_limitation">Wiki</a>
for more information.

<h2>EXAMPLES</h2>

Expand Down
16 changes: 13 additions & 3 deletions temporal/t.rast.series/t.rast.series.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@
# %option G_OPT_R_OUTPUTS
# %end

# %option
# % key: file_limit
# % type: integer
# % description: The maximum number of open files allowed for each r.series process
# % required: no
# % answer: 1000
# %end

# %flag
# % key: t
# % description: Do not assign the space time raster dataset start and end time to the output map
Expand All @@ -78,7 +86,6 @@
# % description: Propagate NULLs
# %end


import grass.script as grass
from grass.exceptions import CalledModuleError

Expand All @@ -96,6 +103,7 @@ def main():
quantile = options["quantile"]
order = options["order"]
where = options["where"]
max_files_open = int(options["file_limit"])
add_time = flags["t"]
nulls = flags["n"]

Expand Down Expand Up @@ -129,10 +137,12 @@ def main():
file.close()

flag = ""
if len(rows) > 1000:
if len(rows) > max_files_open:
grass.warning(
_(
"Processing over 1000 maps: activating -z flag of r.series which slows down processing"
"Processing over {} maps: activating -z flag of r.series which slows down processing.".format(
max_files_open
)
)
)
flag += "z"
Expand Down