Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Urban data demonstrator notebook #3

Merged
merged 2 commits into from
Aug 9, 2021

Conversation

svadams
Copy link

@svadams svadams commented Jul 20, 2021

A PR for contributing an Urban UKV gridded model data demonstrator notebook to the Environmental AI book. The notebook demonstrates:

  • Using Iris to load, visualise and regrid Met Office UKV NetCDF data
  • Using Iris to extract the London region and save as a new NetCDF file

Notes:

  • The data is freely available (link in notebook). For convenience, I have included a sample data daily data file as it is not too big.
  • I have added Iris to the environment.yml file as it takes along time to install - I also think it is generally useful for many use-cases so if we can have it as a standard package it would be good :-)

See Iris docs here: https://scitools-iris.readthedocs.io/en/stable/installing.html

book/urban/sensors/urban-sensors-ukv.ipynb Show resolved Hide resolved
@@ -0,0 +1,397 @@
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's ok to fetch local data but where possible we should show how to fetch from remote URLs. I've tried the lines below but it returns a corrupted file.

base_path = "https://metdatasa.blob.core.windows.net/covid19-response-non-commercial/index.html#metoffice_ukv_daily--t1o5m_mean/"
url= base_path + "ukv_daily_t1o5m_mean_20150801.nc"

filename = url.split('/')[-1]
with fsspec.open(url) as f:
  with Path(filename).open('wb') as handle:
    handle.write(f.read())



Reply via ReviewNB

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I don't have much experience with doing this kind of thing. Might be worth trying this link - https://metdatasa.blob.core.windows.net/covid19-response-non-commercial/metoffice_ukv_daily/t1o5m_mean/ukv_daily_t1o5m_mean_20150801.nc

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe I have found a compromise by using urllib to retrieve the netcdf file into the sample_data directory, i.e:

filepath = 'https://metdatasa.blob.core.windows.net/covid19-response-non-commercial/metoffice_ukv_daily/t1o5m_mean/'
filename = 'ukv_daily_t1o5m_mean_20150801.nc'
urllib.request.urlretrieve(filepath+filename, '../sample_data/' + filename)

I think there are other ways of doing this (e.g. curl or wget), but does assume they are installed on the users system. At least using urllib we can specify it as a dependency in the environment.yml

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

excellent! urllib request is a nice one.

book/urban/sensors/urban-sensors-ukv.ipynb Show resolved Hide resolved
book/urban/sensors/urban-sensors-ukv.ipynb Show resolved Hide resolved
book/urban/sensors/urban-sensors-ukv.ipynb Show resolved Hide resolved
@@ -0,0 +1,397 @@
{
Copy link
Member

@acocac acocac Jul 29, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome!


Reply via ReviewNB

@acocac
Copy link
Member

acocac commented Jul 29, 2021

@svadams Thanks for the contribution. I left some suggestions. Be free to explore them in ReviewNB.
ps. sorry for the late review but I was moving to the UK last week (now in a quarantine hotel).

@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@svadams
Copy link
Author

svadams commented Aug 3, 2021

@acocac - I made some improvements following your suggestions - can you please take another look when you have time :-)

@acocac
Copy link
Member

acocac commented Aug 9, 2021

@svadams, thanks for the improvements, LGTM!
Regarding the notes markdown, most of Jupyter Book’s functionality comes from Sphinx extensions. This means if you want to see this particular markdown for a given ipynb file, you'll need to install the Sphinx plugin in your python interpreter.

@acocac acocac closed this Aug 9, 2021
@acocac acocac merged commit 58fc126 into alan-turing-institute:master Aug 9, 2021
@acocac acocac added the exploration Exploration Notebooks label Sep 21, 2021
@acocac acocac modified the milestone: 0.01 Dec 2, 2021
@acocac acocac added notebook Add/update notebook ready labels Jun 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
exploration Exploration Notebooks medium priority notebook Add/update notebook ready
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants