0

I have hourly netCDF data like this.

   <xarray.Dataset>
Dimensions:       (time: 744)
Coordinates:
    realization   int64 ...
  * time          (time) datetime64[ns] 2019-12-01 ... 2019-12-31T23:00:00
Data variables:
    vimd_NON_CDM  (time) float64 ...

I want to make a heatmap plot of vimd_NON_CDM variable. The y-axis is date from 2019-12-01 to 2019-12-31 and x-axis is hour time in 24h.

How can I make hour as an index from time object like this?

<xarray.DataArray 'time' (time: 744)>
array(['2019-12-01T00:00:00.000000000', '2019-12-01T01:00:00.000000000',
       '2019-12-01T02:00:00.000000000', ..., '2019-12-31T21:00:00.000000000',
       '2019-12-31T22:00:00.000000000', '2019-12-31T23:00:00.000000000'],
      dtype='datetime64[ns]')
Coordinates:
    realization  int64 ...
  * time         (time) datetime64[ns] 2019-12-01 ... 2019-12-31T23:00:00
Attributes:
    long_name:         time
    standard_name:     time
    axis:              T
    stored_direction:  increasing
    type:              double
  • Does [this](https://stackoverflow.com/questions/23139595/dates-in-the-xaxis-for-a-matplotlib-plot-with-imshow) answer your question ? – Liris Sep 24 '20 at 14:24
  • no, it doesnt complete. I think the first step is to select / resample the data first. – xxcdwahahaha Sep 25 '20 at 10:31
  • I don't think you need to resample your data, I guess you need to reshape it. Have a look [here](https://numpy.org/doc/stable/reference/generated/numpy.reshape.html) – Liris Sep 25 '20 at 11:26
  • Yes, it help me. Thank you. – xxcdwahahaha Sep 27 '20 at 07:35

0 Answers0