NASA-DEVELOP / dnppy

DEVELOP National Program Python package for use with NASA data and GIS!
https://nasa-develop.github.io/dnppy/
Other
81 stars 40 forks source link

time_series subsetting functions need to take multiples of "unit" arguments. #24

Open Jwely opened 9 years ago

Jwely commented 9 years ago

presently, there isn't any way to group by some custom interval without multiple representation of each subset.

for example, if i want 3 day summaries, i can use time_series.make_subsets("%d",overlap_width = 1), but this produces a subset centered around every day, while i may want only a subset every 3 days with each data point only represented a single time.

RyanMurphyRI commented 8 years ago

@Jwely, has there been any resolution to this? I am hoping to make 10 day averages from a modis time series, with each data point represented once. Thank you for your work on this!

Jwely commented 8 years ago

I think we worked around it. You can already get what you want out of this function by running a 10 day moving average and throwing out the points that you don't want. It's not a clean solution, so If you need additional syntax help post here again.

RyanMurphyRI commented 8 years ago

@Jwely Yes I would like some syntax help. If I would like to average a 10 year modis time series to 10 day averages, so that for each pixel I would potentially be averaging 10*10 or 100 values, how would I do this?

Jwely commented 8 years ago

I think what you want is to create a rast_series instance, then use the group_bins function with days as the input argument first, then use a make_subsets second.


    rs = tsa.rast_series(args)
    rs.group_bins("%j", cyclical=True)
    rs.make_subsets("%j", overlap_width = 5)

Then take raster statistics on rs

RyanMurphyRI commented 8 years ago

@Jwely as far as I can tell, the "overlap_width" parameter only allows for the creation of a moving window, not a static one to average if I want to get one value for every ten day period that only contains those days that fall within the period, if that makes sense. Have you also seen that even with the specification of a low threshold, make_subsets does not return negative results?

Jwely commented 8 years ago

Regarding the rolling window: yes you are correct, it produces a rolling average. You can still obtain the results you are after by simply deleting the extra results. For example, with a 5 day overlap width, you would end up with 366 separate results, one centered on each day of the year. By keeping the results from julian days 6, 27, 38, 49, 60, etc (according to 6 + 11n) you will have a time series with 11 day averages where each value is represented only a single time.

Regarding negative results, you'll have to be more specific.

RyanMurphyRI commented 8 years ago

Aha! I will try that, although as I understand it the rolling average would produce an average for each day over the entire time series, i.e. 13 years. I would then throw out all unnecessary averages and average those remaining to one single Is that correct?

Thanks Jeff,

On Thu, Oct 29, 2015 at 1:49 PM, Jeff Ely notifications@github.com wrote:

Regarding the rolling window: yes you are correct, it produces a rolling average. You can still obtain the results you are after by simply deleting the extra results. For example, with a 5 day overlap width, you would end up with 366 separate results, one centered on each day of the year. By keeping the results from julian days 6, 27, 38, 49, 60, etc (according to 6

  • 11n) you will have a time series with 11 day averages where each value is represented only a single time.

Regarding negative results, you'll have to be more specific.

— Reply to this email directly or view it on GitHub https://github.com/NASA-DEVELOP/dnppy/issues/24#issuecomment-152263800.

Ryan Murphy International Agricultural Development Graduate Group University of California, Davis