Hi Mathew,
Close enough :)
Instead of cutout["time"] it should be cutout.coords["time"]:
night_hours =
cutout.sel(time=cutout.coords["time"].dt.hour.isin(list(range(18,24))+list(range(0,6))))
Depending on how you are developing, your IDE should've shown you the
cause of the problem. E.g. Jupyter Lab highlights the problematic part
of the code.
Nice to hear the alternative approach also worked. Strange downloads
shouldn't happen. If you observe the mysterious downloads again make
sure to open a bug report on GitHub.
Best,
Am 21/03/2023 um 14:29 schrieb Matthew Smith:
> Hi Johannes,
>
> Thanks for the help!
>
> I thought it would be best to apply the .sel() method to the cutout
> itself. However I wasn't able to. This line:
> /night_hours =
> cutout.sel(time=cutout["time"].dt.hour.isin(list(range(18,24))+list(range(0,6))))/
> Gave the error "TypeError/: 'Cutout' object is not subscriptable"/ which
>
https://github.com/PyPSA/atlite/blob/17c81f9bee46752a89e31d5c28dc9e0b5fb107b9/atlite/convert.py#L462 <
https://github.com/PyPSA/atlite/blob/17c81f9bee46752a89e31d5c28dc9e0b5fb107b9/atlite/convert.py#L462>
>
> IIRC we did implement the .sel(...) method for the cutout itself, so
> you
> could try producing "sub-cutouts" based on your original cutout and
> then
> calling the .wind(...) method on those. The syntax should be the same.
>
> HTH, Johannes
>
>
> Best regards,
> Johannes Hampp (he/him)
>
> Justus Liebig University Giessen (JLU)
> Center for international Development and Environmental Research (ZEU)
>
> mailto:
johanne...@zeu.uni-giessen.de
>
> Senckenbergstr. 3
> DE-35392 Giessen
>
https://uni-giessen.de/zeu <
https://uni-giessen.de/zeu>
> >
ws_ratio.name <
http://ws_ratio.name> = 'Wind Speed day night ratio'
> <
http://cap_factors_ratio.name <
http://cap_factors_ratio.name>> =
> 'Capacity
> > Factor Ratio night/day'
> > cap_factors_ratio.plot(ax=ax, transform=plate(), alpha=0.8)
> > cells.plot(ax=ax, **plot_grid_dict)
> > #ax.outline_patch.set_edgecolor('white')
> > fig.tight_layout();
> >
> > On Monday, 6 March 2023 at 10:25:49 UTC+5:30 Matthew Smith wrote:
> >
> > Thanks Fabian. I'll come back to the group with results once I
> > make some progress.
> >
> > On Thursday, 2 March 2023 at 18:06:58 UTC+5:30 Fabian Hofmann wrote:
> >
> > Hey Matt,
> >
> >
> > since atlite is mainly using slices, it is not perfectly
> > designed for such selective time-series during the cutout
> > creation. I would suggest to create the cutout for the whole
> > year (or multiple) and select the relevant times after the
> > calculation of the power generation. With pandas/xarray you
> > can do powerful selection, groupby or resample operations
> > (which to explain would be out of the scope here). Have a
> > look at the example here
> >
>
https://docs.xarray.dev/en/stable/generated/xarray.DataArray.groupby.html <
https://docs.xarray.dev/en/stable/generated/xarray.DataArray.groupby.html> <
https://docs.xarray.dev/en/stable/generated/xarray.DataArray.groupby.html <
https://docs.xarray.dev/en/stable/generated/xarray.DataArray.groupby.html>> for getting started.
> >
> >
> > Hope that helps for the start.
> >
> >
> > Best
> >
> > Fabian Hofmann
> >
> >
> > On 02.03.23 13:28, Matthew Smith wrote:
> >> Hello,
> >>
> >> Thanks again to this great community.
> >>
> >> I have a question about Atlite. The application of this
> >> would be to create season-specific or time specific analysis.
> >>
> >> Is it possible to average specific times throughout the
> >> year? For example, if I'd like to create a generation map
> >> which shows the average annual generation only for the
> >> hours of 6pm to 6am, would it be possible to group the
> >> times in that way?
> >>
> >> Related but perhaps different, are we able to download a
> >> cut-out for only those hours across all days of the year
> >> or multiple years?
> >>
> >> Best regards,
> >> Matt
> >> --
> >> You received this message because you are subscribed to
> >> the Google Groups "pypsa" group.
> >> To unsubscribe from this group and stop receiving emails
> >> from it, send an email to
pypsa+un...@googlegroups.com.
> >> To view this discussion on the web, visit
> >>
>
https://groups.google.com/d/msgid/pypsa/355503e8-d73f-4ee3-803e-618ffe57b737n%40googlegroups.com <
https://groups.google.com/d/msgid/pypsa/355503e8-d73f-4ee3-803e-618ffe57b737n%40googlegroups.com> <
https://groups.google.com/d/msgid/pypsa/355503e8-d73f-4ee3-803e-618ffe57b737n%40googlegroups.com?utm_medium=email&utm_source=footer <
https://groups.google.com/d/msgid/pypsa/355503e8-d73f-4ee3-803e-618ffe57b737n%40googlegroups.com?utm_medium=email&utm_source=footer>>.
> <
https://tub-ensys.github.io/> <
https://tub-ensys.github.io/
>
https://groups.google.com/d/msgid/pypsa/85f10e65-716c-4f44-a637-8faefb06ff01n%40googlegroups.com <
https://groups.google.com/d/msgid/pypsa/85f10e65-716c-4f44-a637-8faefb06ff01n%40googlegroups.com> <
https://groups.google.com/d/msgid/pypsa/85f10e65-716c-4f44-a637-8faefb06ff01n%40googlegroups.com?utm_medium=email&utm_source=footer <
https://groups.google.com/d/msgid/pypsa/85f10e65-716c-4f44-a637-8faefb06ff01n%40googlegroups.com?utm_medium=email&utm_source=footer>>.
>
> --
> You received this message because you are subscribed to the Google
> Groups "pypsa" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to
pypsa+un...@googlegroups.com
> <mailto:
pypsa+un...@googlegroups.com>.
> To view this discussion on the web, visit
>
https://groups.google.com/d/msgid/pypsa/359b1a24-2d76-467e-8f97-a83b19111b18n%40googlegroups.com <
https://groups.google.com/d/msgid/pypsa/359b1a24-2d76-467e-8f97-a83b19111b18n%40googlegroups.com?utm_medium=email&utm_source=footer>.