Hi Veronica,
thank you for your input regarding the registering maps with 0.25*months time steps.
Here the solution I came up with was to import the maps in groups of 4 bands from the netCDF file. Then I calculate average over the 4 monthly map and register the average map as a single map for the respective months:
Register raster maps to assign correct date
scpdsi_maps_no = range(1,2688+1) # Total number of bands/maps
scpdsi_maps_groups_month = [scpdsi_maps_no[i:i + 4] for i in xrange(0, len(scpdsi_maps_no), 4)]
scpdsi_maps_groups_monthyear = [scpdsi_maps_groups_month[i:i + 12] for i in xrange(0, len(scpdsi_maps_groups_month), 12)]
year=1961 # First year
for idx, i in enumerate(scpdsi_maps_groups_monthyear):
month=1 # First month
for j in i:
print(str(year) + “-” + str(month).zfill(2) + “-01”)
grass.run_command(“r.import”,
flags=“o”,
overwrite=True,
input=“/path/to/my/scpdsi.nc”,
band=j,
extent=“region”,
output=“scPDSI”)
scpdsi_maps = [“scPDSI.”+str(x) for x in j]
grass.run_command(“r.series”,
overwrite=True,
input=scpdsi_maps,
output=“scPDSI”+“-”+str(year)+“-”+str(month).zfill(2),
method=“average”)
grass.run_command(“g.remove”,
flags=“f”,
type=“raster”,
name=scpdsi_maps)
grass.run_command(“t.register”,
overwrite=True,
#flags=“i”,
type=“raster”,
input=“scPDSI_monthly”,
maps=“scPDSI”+“-”+str(year)+“-”+str(month).zfill(2),
start=str(year) + “-” + str(month).zfill(2) + “-01”,
increment=“1 months”)
month=month+1
year=year+1
This solution works fine for me.
/Johannes
···
On Tue, Oct 24, 2017 at 7:04 PM, Veronica Andreo <veroandreo@gmail.com> wrote:
Hello Johanes,
there’s and example in t.register manual page with netCDF files [0] that might help. You would have 48 maps per year (IMHO, 0.25*month is a bit strange as time step, but well). I would say that you need to write a script to get dates for each 1/4 of a month (maybe someone else know of a function to do a similar task, dunno) in your time series and then make a file with mapname|start_time|end_time to pass to t.register.
However, if you only need to estimate yearly means and long term means, you can use r.series [1] with every 48 maps for yearly means and, the whole list of maps for the long term mean.
hth,
Vero
[0] https://grass.osgeo.org/grass72/manuals/t.register.html
[1] https://grass.osgeo.org/grass72/manuals/r.series.html
2017-10-24 11:56 GMT+02:00 Johannes Radinger <johannesradinger@gmail.com>:
Hi,
I am very new to the temporal functionalities of GRASS. Specifically I have a netCDF file that contains many layers where each layer represents a raster map of a drought index (http://monitordesequia.csic.es/map/) for a timepoint of a timeseries. The time series is from 1/1961 to 12/2015 with 4 maps for each month. So these are not really weekly maps but maps with an interval of 0.25months. The layers of the netCDF are only numbered consecutively so there is no indication of a specific date etc. (I just now that they start with 1/1961 and then the interval of 0.25months). What would be the procedure to register these raster maps in GRASS so that I can calculate later only e.g. yearly means and a long-time year average?
Best regards,
Johannes
grass-user mailing list
grass-user@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-user