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

Comments on accessing s3 #10

Merged
merged 2 commits into from
Jun 27, 2022

Conversation

dcherian
Copy link
Contributor

@dcherian dcherian commented Jun 24, 2022

This notebook is great. I just have minor comments on increasing readabillity

@@ -110,15 +115,26 @@
"metadata": {},
"outputs": [],
"source": [
"dc1 = xr.open_dataset(url1, engine= 'zarr',\n",
"dc1 = xr.open_dataset(url1, engine= 'zarr', chunks=\"auto\",\n",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This makes the repr faster. I'll open an xarray issue

@@ -127,11 +143,8 @@
"metadata": {},
"outputs": [],
"source": [
"def get_bbox_single(input_xr):\n",
"def get_bounds_polygon_4326(input_xr):\n",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

refactoring this piece out simplifies the code later

"\n",
" #format question - better to condense this into 1 line or break into 3 to be more readable?\n",
" http_url = input_dict['features'][granule]['properties']['zarr_url']\n",
" for granule in input_dict['features']:\n",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

note how using python's iterating feature makes the code simpler and more readable.

Comment on lines +419 to +420
" ### alternatively use list comprehension\n",
" # poly_ls = [get_bounds_polygon(xr_obj).to_crs('epsg:4326') for xr_obj in input_ls]\n",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The following pattern

out = []
for a in b:
    ...
   out.append(...)

is usually a good place to use a list comprehension.

@dcherian dcherian mentioned this pull request Jun 24, 2022
@@ -449,7 +468,7 @@
"metadata": {},
"outputs": [],
"source": [
"get_bbox_group(dc_ls, [70, 98, 20, 60])"
"get_bbox_group(dc_ls, bounds=[70, 98, 20, 60])"
Copy link
Contributor Author

@dcherian dcherian Jun 24, 2022

Choose a reason for hiding this comment

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

Writing out bounds= is nice because then future-you knows what that list is supposed to mean without looking up the function.

You could enforce this by changing the signature to

def get_bbox_grouop(input_xr, *, bounds=[...])

With this you can only set bounds by writing out bounds=.

@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@e-marshall e-marshall marked this pull request as ready for review June 27, 2022 18:05
@e-marshall e-marshall merged commit 9d50e11 into e-marshall:master Jun 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants