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

Fix bugs and use real data in the plotting docs #251

Merged

Conversation

adybbroe
Copy link
Contributor

@adybbroe adybbroe commented Feb 6, 2020

Fix bugs and use real data in the doc pages but hide code needed for doc testing

There was also one duplicated section which is now fixed.

The idea is that the user should be able more or less to generate the same plots by going from top to bottom in a notebook or ipython prompt.

Signed-off-by: Adam.Dybbroe [email protected]

  • Closes #xxxx
  • Tests added
  • Tests passed
  • Passes git diff origin/master **/*py | flake8 --diff
  • Fully documented

@adybbroe
Copy link
Contributor Author

adybbroe commented Feb 6, 2020

Should be ready now.
One thing which is lacking is some help on how to get the background blue marble ready for Cartopy. Didn't find a nice description/manual for this online when I was looking now. But locally I have this json file:

➜  raster more images.json 
{"__comment__": "JSON file specifying the image to use for a given type/name and resolution. Read in by cartopy.mpl.geoaxes.read_user_background_images.",
  "BM": {
    "__comment__": "Blue Marble Next Generation, July ",
    "__source__": "https://neo.sci.gsfc.nasa.gov/view.php?datasetId=BlueMarbleNG-TB",
    "__projection__": "PlateCarree",
    "low": "BM.jpeg",
    "high": "BMNG_hirez.png"},
    "pop": {
    "__comment__": "Population density from Nasa earth observations website",
    "__source__": "https://neo.sci.gsfc.nasa.gov/view.php?datasetId=SEDAC_POP",
    "__projection__": "PlateCarree",
    "high": "population.jpg"}
}

and a jpeg file BM.jpeg in the same directory. And that directory is pointed to by CARTOPY_USER_BACKGROUNDS

I actually have these four files in my local directory:

BM.jpeg
BMNG_hirez.png
images.json
population.jpg

Probably only BM.jpeg is needed
Any suggestions welcome!

@adybbroe adybbroe marked this pull request as ready for review February 6, 2020 13:28
>>> tb37v = np.arange(1000)
>>> area_def = load_area('areas.yaml', 'pc_world')
>>> swath_def = SwathDefinition(lons, lats)
>>> area_def = load_area('areas.yaml', 'pc_world') # doctest: +SKIP
Copy link
Member

Choose a reason for hiding this comment

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

Isn't this area load just overwriting the area_def created in the lines above?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, right. But the stuff above is hidden, and does not show up on RTD. Therefore the additional line for RTD. The area is not defined and on Travis we don't have access to areas.yaml and certainly not in the home dir.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, pyresample doesn't have a builtin areas 🤦‍♂️ Got it.

Copy link
Member

@djhoese djhoese left a comment

Choose a reason for hiding this comment

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

Thanks for looking at this Adam. I'm a little confused by the doctest skips. Does doctest only run the code in .. doctest sections or do it run all code that it finds? Can we just not doctest some of these parts? It seems like some lines have a skipped doctest and others don't, but shouldn't they work? Like the load_area calls should be loading the areas.yaml from the package, right?

Signed-off-by: Adam.Dybbroe <[email protected]>
@adybbroe
Copy link
Contributor Author

adybbroe commented Feb 6, 2020

I am also not pleased with it really. I am using this doctest-hide to help doctesting but hiding it for the user.
I haven't found a way to skip a whole block when testing.

@djhoese
Copy link
Member

djhoese commented Feb 20, 2020

Looks like there are some import issues on the tests. @adybbroe Could you look at these?

@coveralls
Copy link

coveralls commented Apr 22, 2020

Coverage Status

Coverage increased (+0.05%) to 91.969% when pulling 9e70cd5 on adybbroe:fix-documentation-error-cartopy-plotting into 3d6d38d on pytroll:master.

@codecov
Copy link

codecov bot commented Apr 22, 2020

Codecov Report

Merging #251 into master will increase coverage by 0.04%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #251      +/-   ##
==========================================
+ Coverage   91.94%   91.99%   +0.04%     
==========================================
  Files          42       42              
  Lines        8098     8181      +83     
==========================================
+ Hits         7446     7526      +80     
- Misses        652      655       +3     
Impacted Files Coverage Δ
pyresample/plot.py 42.37% <ø> (+0.70%) ⬆️
pyresample/utils/_proj4.py 86.95% <0.00%> (-1.57%) ⬇️
pyresample/test/test_geometry.py 97.75% <0.00%> (-0.15%) ⬇️
pyresample/bucket/__init__.py 98.91% <0.00%> (-0.06%) ⬇️
pyresample/test/test_grid.py 100.00% <0.00%> (ø)
pyresample/test/test_bucket.py 100.00% <0.00%> (ø)
pyresample/test/test_kd_tree.py 97.28% <0.00%> (+0.05%) ⬆️
pyresample/test/test_utils.py 97.37% <0.00%> (+0.13%) ⬆️
pyresample/geometry.py 82.55% <0.00%> (+0.14%) ⬆️
pyresample/kd_tree.py 92.47% <0.00%> (+0.17%) ⬆️
... and 2 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3d6d38d...9e70cd5. Read the comment docs.

@adybbroe adybbroe closed this May 4, 2020
@adybbroe adybbroe reopened this May 4, 2020
@adybbroe adybbroe closed this May 4, 2020
@adybbroe
Copy link
Contributor Author

adybbroe commented May 4, 2020

Closing and reopening the PR to try trigger a RTD build

@adybbroe adybbroe reopened this May 4, 2020
@adybbroe
Copy link
Contributor Author

adybbroe commented May 4, 2020

I think I am ready with this PR now, and now one can see the doc-pages being build on RTD for PRs.
Except that I here see the # doctest: +SKIP (I suppose they will be gone once merged?) I believe it is ready. Perhaps @TomLav @mraspaud @djhoese or someone else want to go through it quickly?

@djhoese
Copy link
Member

djhoese commented May 7, 2020

@mraspaud @adybbroe I think this should be good now. I made one important change to the code that could cause issues for some people: I remove the matplotlib.use line in the save_quicklook function. It was using a warn keyword argument that is being deprecated in matplotlib 3.3 and I personally don't think a function should be setting the matplotlib backend for the user. If this was a known problem and was needed in the past we can revisit it. Otherwise I'm going to assume modern matplotlib behaves better for this.

@djhoese djhoese merged commit 92ad021 into pytroll:master May 12, 2020
@djhoese djhoese changed the title Fix bugs and use real data in the doc pages but hide code needed for … Fix bugs and use real data in the plotting docs May 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants