Тёмный

How to get data out of a NetCDF file using Python: depth profile 

Luke Data Manager
Подписаться 892
Просмотров 12 тыс.
50% 1

Опубликовано:

 

19 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 19   
@samuelb1004
@samuelb1004 Год назад
Legendary!
@LukeDataManager
@LukeDataManager 5 месяцев назад
💪
@MuhammadAsim-mh4xo
@MuhammadAsim-mh4xo 2 года назад
Thanks, Luke
@LukeDataManager
@LukeDataManager 2 года назад
You're welcome 🙂
@fransiscojefta
@fransiscojefta 13 дней назад
Thank you so much Sir your tutorial helps me a lot. it's so insightful! but i have a couple of questions sir: 1. just to make sure, does the prompt from line 1-18 works in jupyter notebook? 2. If I use a monthly climatology timeframe, does that mean I should average each month first before following the prompt in this video? Thank you so much, have a nice day Sir!
@LukeDataManager
@LukeDataManager 12 дней назад
Pretty much all python code can work in jupyter notebook. Regarding your data it really depends what you are trying to achieve.
@reshmasharma7889
@reshmasharma7889 Год назад
very helpful
@LukeDataManager
@LukeDataManager 5 месяцев назад
Thanks!
@MatinaNikolopoulou-dp5cz
@MatinaNikolopoulou-dp5cz Год назад
Hi Luke, Thank you for this video, it's very helpful. Is it possible to extract only one variable from a netcdf to a new one. I have a netcdf with many variables and I want to extract to a netcdf the one that is called 'temp' , it has dimensions 'time', 'lat', 'lon'.
@LukeDataManager
@LukeDataManager Год назад
Hi Matina, you can look at this Jupyter Notebook on accessing data with multiple dimensions: github.com/lhmarsden/NetCDF-CF_workshops/blob/main/Python_workshop_materials/xarray_analyse_ctd_data_whole_cruise.ipynb
@alial-wakeel8435
@alial-wakeel8435 2 года назад
Hi Luke, Many thanks for sharing this video. I'm wondering how is it possible to extract data (of a variable) from a netCDF file by date? Or between two dates. To elaborate, I have hourly data of temperature over three years. However, I need to extract those for exactly one year. How is this possible using xarray? I really appreciate any possible help with this,
@LukeDataManager
@LukeDataManager 2 года назад
Thanks. If I was doing this, I would first export my variable to a Pandas dataframe df = data['TEMPERATURE'].to_dataframe() You should now have a dataframe with two columns, time and temperature. You then need to convert your times (probably in hours since time X) to actual datetime values, something like below where 'start_datetime' is a datetime value: df['DATETIMES'] = start_datetime + pd.to_timedelta(df['TIME'], unit='h') The you need to extract your trim down your dataframe between two desired dates. This is nicely addressed in this answer on stackoverflow: stackoverflow.com/a/29370182/14125020
@alial-wakeel8435
@alial-wakeel8435 2 года назад
@@LukeDataManager So many thanks for the help, Luke. In fact, I started developing one similar approach taking into consideration the number of hours per (leap) year. It works but quite slow, so I will check your approach and see if I can get quicker results. Once again, I really appreciate your help.
@ShelbyWilliamsJr
@ShelbyWilliamsJr Год назад
Luke, how should the code be changed to access this data: [3110400 values with dtype=float32] Coordinates: * time (time) datetime64[ns] 1901-01-16 1901-02-16 ... 1901-12-16 * lat (lat) float32 -89.75 -89.25 -88.75 -88.25 ... 88.75 89.25 89.75 * lon (lon) float32 -179.8 -179.2 -178.8 -178.2 ... 178.8 179.2 179.8 Attributes: time_op_ncl: Climatology: 30 years long_name: near-surface temperature units: degC correlation_decay_distance: 1200.0 -Thanks!
@LukeDataManager
@LukeDataManager Год назад
Hi Shelby, it is difficult for me to know without seeing the variables and what dimensions you have, but you can look at this Jupyter Notebook on accessing data with multiple dimensions: github.com/lhmarsden/NetCDF-CF_workshops/blob/main/Python_workshop_materials/xarray_analyse_ctd_data_whole_cruise.ipynb
@LukeDataManager
@LukeDataManager Год назад
So if you have a variable called 'TEMP' with dimensions 'time', 'lat', 'lon' you can dump the variable to a Pandas dataframe df = data['TEMP'].to_dataframe()
@tilmanmarschallek4602
@tilmanmarschallek4602 9 месяцев назад
Thanks for the nice Video. Unfortunately I have a problem. I installed xarray with conda. Only problem, when I type in „Import xarray as xr“, the error code: on module named ‘xarray‘ shows up. Any idea how to solve that problem? Chers
@LukeDataManager
@LukeDataManager 9 месяцев назад
Hi, thanks for the comment. It is difficult for me to troubleshoot this without more information. Are you using multiple conda environments? It is difficult to solve this kind of problem without sitting at your computer with you. I advise writing a question clearly explaining your problem on stackoverflow
@tilmanmarschallek4602
@tilmanmarschallek4602 9 месяцев назад
Thanks a lot. Keep up the work👋🏼
Далее
How to open a NetCDF file (NetCDF in Python #01)
18:11
Просмотров 4,9 тыс.
Introducing NetCDF and the CF and ACDD conventions
12:16
Visualising data in NetCDF format
39:56
Просмотров 65 тыс.