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

Ez plot #18

Merged
merged 14 commits into from
Jan 23, 2018
Merged

Ez plot #18

merged 14 commits into from
Jan 23, 2018

Conversation

jccosta
Copy link
Contributor

@jccosta jccosta commented Jan 9, 2018

These the changes for EzPlot, a new library aiming to help users creating really nice plots.

@doutriaux1
Copy link
Contributor

@jccosta this seems REALLY nice. Can I request that you make a jupyter notebook of the html documentation? That's our way of exposing docs these days.

@jccosta
Copy link
Contributor Author

jccosta commented Jan 9, 2018

Sure, I will do it. I have other 4 jupyter notebooks with examples. Where should I put them? In Doc directory?

@doutriaux1
Copy link
Contributor

please create a Jupyter directory in Doc yes. Thanks! The more the merrier!

@doutriaux1
Copy link
Contributor

@jccosta a user asked the following about https://github.com/UV-CDAT/vcsaddons/pull/18/files

Could controlling the font/size be added to this?

@jccosta
Copy link
Contributor Author

jccosta commented Jan 9, 2018

Yes, will do it.

@jccosta
Copy link
Contributor Author

jccosta commented Jan 10, 2018

Done!

@doutriaux1
Copy link
Contributor

Awesome! Will review this week! @danlipsa and @aashish24 please review as well.

@doutriaux1
Copy link
Contributor

installed vcs branch EzPlot when running example1 nb i get:

/Users/doutriaux1/anaconda2/envs/nightly2/lib/python2.7/site-packages/vcsaddons/EzLinePlot.pyc in lineplot(self, data, canvas, template, line, linetypes, linewidths, linecolors, backgroundcolor, colormap, randomcolor, title, titlesize, left_label, right_label, bottom_label, top_label, verticallabelsize, horizontallabelsize, marker, markercolors, markertypes, markersizes, legendtexts, legendscratched, legendtextcolors, legendposition, legendstacking, legenddrawbackground, legendbackgroundcolor, legendsmallestfontsize, tick_sides, framewidth, autoxaxis, autoyaxis, min_y, max_y, min_x, max_x, x_labels, y_labels, enablegrid)
    493         if templates.x.getfontname(1) is not "DejaVuSans":
    494             try:
--> 495                 templates.x.switchfonts("default", "DejaVuSans")
    496             except vcs.error.vcsError:
    497                 print

/Users/doutriaux1/anaconda2/envs/nightly2/lib/python2.7/site-packages/vcs/Canvas.pyc in switchfonts(self, font1, font2)
   5908                 font1)
   5909         if isinstance(font2, str):
-> 5910             index2 = self.getfont(font2)
   5911         elif isinstance(font2, (int, float)):
   5912             index2 = int(font2)

/Users/doutriaux1/anaconda2/envs/nightly2/lib/python2.7/site-packages/vcs/Canvas.pyc in getfont(self, font)
   5872             return self.getfontname(font)
   5873         elif isinstance(font, str):
-> 5874             return self.getfontnumber(font)
   5875         else:
   5876             raise vcsError("Error you must pass a string or int")

/Users/doutriaux1/anaconda2/envs/nightly2/lib/python2.7/site-packages/vcs/Canvas.pyc in getfontnumber(self, name)
   5834 
   5835     def getfontnumber(self, name):
-> 5836         return vcs.getfontnumber(name)
   5837     getfontnumber.__doc__ = vcs.utils.getfontnumber.__doc__
   5838 

/Users/doutriaux1/anaconda2/envs/nightly2/lib/python2.7/site-packages/vcs/utils.pyc in getfontnumber(name)
    499         if vcs.elements["fontNumber"][i] == name:
    500             return i
--> 501     raise Exception("Font name not existing! %s" % name)
    502 
    503 

Exception: Font name not existing! DejaVuSans

@doutriaux1
Copy link
Contributor

Also notebooks shouldn't be in a

if __name__ == "__main__":

@doutriaux1
Copy link
Contributor

runnnig Jerry example i get:

---------------------------------------------------------------------------
CDMSError                                 Traceback (most recent call last)
<ipython-input-1-f5afb8d12c59> in <module>()
     52 
     53     # open the file from the OPENDAP address
---> 54     f1 = cdms2.open(file1)
     55 
     56     # read the variable (end date can be a date like '1989-01-16')

/Users/doutriaux1/anaconda2/envs/nightly2/lib/python2.7/site-packages/cdms2/dataset.pyc in openDataset(uri, mode, template, dods, dpath, hostObj)
    359             # rank
    360             if not os.path.exists(path):
--> 361                 return CdmsFile(path, mode, mpiBarrier=CdMpi)
    362             elif mode == "w":
    363                 try:

/Users/doutriaux1/anaconda2/envs/nightly2/lib/python2.7/site-packages/cdms2/dataset.pyc in __init__(self, path, mode, hostObj, mpiBarrier)
   1095             _fileobj_ = Cdunif.CdunifFile(path, mode)
   1096         except Exception as err:
-> 1097             raise CDMSError('Cannot open file %s (%s)' % (path, err))
   1098         self._file_ = _fileobj_   # Cdunif file object
   1099         self.variables = {}

CDMSError: Cannot open file /git/vcsaddons/EzPlot/Doc/Jupyter/tas1.ncml (No error)

@jccosta
Copy link
Contributor Author

jccosta commented Jan 22, 2018

Removed the "main" form the notebooks examples.
About Jerry example, the files must be downloaded if not present. I left the command commented in the notebook for users that want to reproduce it and don't have the files.
Can you try it again now that I changed the new fonts positions? It is working fine here.

@doutriaux1
Copy link
Contributor

thx.

do you mind adding something like this in the jerry nb

import requests
if not os.path.exists("clt.nc"):
    r = requests.get("https://uvcdat.llnl.gov/cdat/sample_data/clt.nc",stream=True)
    with open("clt.nc","wb") as f:
        for chunk in r.iter_content(chunk_size=1024):
            if chunk:  # filter local_filename keep-alive new chunks
                f.write(chunk)

@jccosta
Copy link
Contributor Author

jccosta commented Jan 22, 2018

I forgot to add the new fonts in the setup file. It's fixed now.

@jccosta
Copy link
Contributor Author

jccosta commented Jan 22, 2018

Added downloading of missing files in Jerry's example.

@doutriaux1
Copy link
Contributor

almost there, everything works except JerrY:

---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-1-94e57c3ec0bc> in <module>()
     39 # go to https://dataserver.nccs.nasa.gov/thredds/catalog/bypass/CREATE-IP/catalog.html
     40 if not os.path.exists("tas1.ncml"):
---> 41     r = requests.get("https://dataserver.nccs.nasa.gov/thredds/dodsC/bypass/CREATE-IP/reanalysis/MERRA2/mon/atmos/tas.ncml",stream=True)
     42     with open("tas1.ncml","wb") as f:
     43         for chunk in r.iter_content(chunk_size=1024):

NameError: name 'requests' is not defined

Sorry it's in your repo so I can't edit.

@doutriaux1
Copy link
Contributor

looks like the ncml isn't enough

---------------------------------------------------------------------------
CDMSError                                 Traceback (most recent call last)
<ipython-input-2-537201bf04f8> in <module>()
     62 
     63 # open the file from the OPENDAP address
---> 64 f1 = cdms2.open(file1)
     65 
     66 # read the variable (end date can be a date like '1989-01-16')

/Users/doutriaux1/anaconda2/envs/nightly2/lib/python2.7/site-packages/cdms2/dataset.pyc in openDataset(uri, mode, template, dods, dpath, hostObj)
    368 
    369             # The file exists
--> 370             file1 = CdmsFile(path, "r")
    371             if libcf is not None:
    372                 if hasattr(file1, libcf.CF_FILETYPE):

/Users/doutriaux1/anaconda2/envs/nightly2/lib/python2.7/site-packages/cdms2/dataset.pyc in __init__(self, path, mode, hostObj, mpiBarrier)
   1095             _fileobj_ = Cdunif.CdunifFile(path, mode)
   1096         except Exception as err:
-> 1097             raise CDMSError('Cannot open file %s (%s)' % (path, err))
   1098         self._file_ = _fileobj_   # Cdunif file object
   1099         self.variables = {}

CDMSError: Cannot open file /git/vcsaddons/EzPlot/Doc/Jupyter/tas1.ncml (No error)

But they're opendap files, why don't you plug the opendap file names url in cdms?

the "requests" bit leads to files with this in for me:

Error {
    code = 400;
    message = "Unrecognized request";
};

but using the URL seems to make it hang forever

@jccosta
Copy link
Contributor Author

jccosta commented Jan 22, 2018

It seems that path for the files have changed. I updated it for what seems to be the new path. Can you test it?

@doutriaux1
Copy link
Contributor

@jccosta getting there the ncml files now have:

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>TDS - Error report</title>
    <link rel="stylesheet" href="/thredds/tds.css" type="text/css"/>
  </head>
  <body>
    <h1>HTTP Status 404 - Not Found</h1>
    <HR size="1" noshade="noshade">
    <p><b>Status</b> 404 - Not Found</p>
    <HR size="1" noshade="noshade">
    <h3>THREDDS Data Server Version 4.6
      -- <a href='http://www.unidata.ucar.edu/software/thredds/v4.6/tds/TDS.html'>Documentation</a></h3>
  </body>
</html>

but cdms2 if barfing on them, trying on my end to put the new URL directly in

@doutriaux1
Copy link
Contributor

doh... still no luck

---------------------------------------------------------------------------
CDMSError                                 Traceback (most recent call last)
<ipython-input-2-c0cf9b3d7d7e> in <module>()
     48 
     49 # open the file from the OPENDAP address
---> 50 f1 = cdms2.open(file1)
     51 
     52 # read the variable (end date can be a date like '1989-01-16')

/Users/doutriaux1/anaconda2/envs/nightly2/lib/python2.7/site-packages/cdms2/dataset.pyc in openDataset(uri, mode, template, dods, dpath, hostObj)
    402                         os.path.expanduser("~"), ".dodsrc")):
    403                     msg += "\nYou have a .dodsrc in your HOME directory, try to remove it"
--> 404                 raise CDMSError(msg)
    405         else:
    406             try:

CDMSError: Error in DODS open of: https://dataserver.nccs.nasa.gov/thredds/catalog/bypass/CREATE-IP/reanalysis/MERRA2/mon/atmos/tas.ncml

@doutriaux1
Copy link
Contributor

@jccosta even netcdf doesn't like it:

ncdump -h https://dataserver.nccs.nasa.gov/thredds/catalog/bypass/CREATE-IP/reanalysis/MERRA2/mon/atmos/tas.ncml
syntax error, unexpected WORD_WORD, expecting SCAN_ATTR or SCAN_DATASET or SCAN_ERROR
context: <html^ xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>TDS - Error report</title> <link rel="stylesheet" href="/thredds/tds.css" type="text/css"/> </head> <body> <h1>HTTP Status 404 - Not Found</h1> <HR size="1" noshade="noshade"> <p><b>Status</b> 404 - Not Found</p> <HR size="1" noshade="noshade"> <h3>THREDDS Data Server Version 4.6 -- <a href='http://www.unidata.ucar.edu/software/thredds/v4.6/tds/TDS.html'>Documentation</a></h3> </body></html>
ncdump: https://dataserver.nccs.nasa.gov/thredds/catalog/bypass/CREATE-IP/reanalysis/MERRA2/mon/atmos/tas.ncml: NetCDF: file not found

@doutriaux1
Copy link
Contributor

@jccosta I'm on Mac, are on Mac as well?

@jccosta
Copy link
Contributor Author

jccosta commented Jan 22, 2018

It is a problem with Nasa server. If you got to https://dataserver.nccs.nasa.gov/thredds/dodsC/bypass/CREATE-IP/reanalysis/ECMWF/mon/atmos/tas.ncml.html you can see that the data URL they are providing isn't working. You can download the file clicking in the binary button on top, tough.
Is maybe better to remove this example?

@jccosta
Copy link
Contributor Author

jccosta commented Jan 22, 2018

I'm on Mac too.

@doutriaux1
Copy link
Contributor

Let me try to download the files and upload them back on our server.

@jccosta
Copy link
Contributor Author

jccosta commented Jan 22, 2018

I opened the js code in the page and I realized they added a different extension for the files. I updated the path. Can you try it?

@doutriaux1
Copy link
Contributor

I can't get it to go... Even when I download the files manually. Can you use cos/sin please or just take it out? Thanks.

@jccosta
Copy link
Contributor Author

jccosta commented Jan 23, 2018

I removed the example. We already have a sin/cos example.

@doutriaux1 doutriaux1 merged commit 623b4e4 into CDAT:master Jan 23, 2018
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