<div dir="ltr"><div>Hi Jachym, </div><div><br></div>Thanks for the pointers, I've started writing validators for netCDF. I'm still wondering where the decision to download a file is made? Can I shortcut that decision and avoid a file download if the href is a valid opendap link, ie it passes the validatenetcdf checks?<div><br></div></div><br><div class="gmail_quote"><div dir="ltr">On Fri, Jun 22, 2018 at 4:53 AM Jachym Cepicky <<a href="mailto:jachym.cepicky@gmail.com">jachym.cepicky@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Hi,</div><div><br></div><div>yes ComplexInput should work for you - you can pass the url with the data using "<Reference ... />" element.. see [1] for example<br></div><div><br></div><div>Any Format can have (and has by default) `validator` function, which return's, whether the input data are valid or no [3]. You can also use `get_format` function [4] and set the validator there.</div><div><br></div><div>Example, how validating function can look can be shapefile or gml validators [5]<br></div><div><br></div><div>You should probably extend foramts [2] with NetCDF mimetype</div><div><br></div><div>But, this will check the file only after it was downloaded to PyWPS - not the URL. Still. is that sufficient? <br></div><div><br></div><div>Jachym<br></div><div><br></div><div>[1] <a href="https://github.com/geopython/pywps/blob/master/tests/requests/wps_execute_request-responsedocument-1.xml#L24" target="_blank">https://github.com/geopython/pywps/blob/master/tests/requests/wps_execute_request-responsedocument-1.xml#L24</a></div><div>[2] <a href="https://github.com/geopython/pywps/blob/master/pywps/inout/formats/__init__.py" target="_blank">https://github.com/geopython/pywps/blob/master/pywps/inout/formats/__init__.py</a></div><div>[3] <a href="https://github.com/geopython/pywps/blob/master/pywps/inout/formats/__init__.py#L42" target="_blank">https://github.com/geopython/pywps/blob/master/pywps/inout/formats/__init__.py#L42</a></div><div>[4] <a href="https://github.com/geopython/pywps/blob/master/pywps/inout/formats/__init__.py#L215" target="_blank">https://github.com/geopython/pywps/blob/master/pywps/inout/formats/__init__.py#L215</a></div><div>[5] <a href="https://github.com/geopython/pywps/blob/master/pywps/validator/complexvalidator.py" target="_blank">https://github.com/geopython/pywps/blob/master/pywps/validator/complexvalidator.py</a></div><div><br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr">čt 21. 6. 2018 v 17:15 odesílatel David Huard <<a href="mailto:huard.david@ouranos.ca" target="_blank">huard.david@ouranos.ca</a>> napsal:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"></blockquote></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi all, <div><br></div><div>I'd like to contribute a pull request to better handle netCDF files in pywps but I don't know where to start. </div><div><br></div><div>We have a number of processes taking <a href="https://www.unidata.ucar.edu/software/netcdf/" target="_blank">netCDF</a> files as inputs. For those less familiar with the format, netCDF is based on HDF5 and a set of <a href="http://cfconventions.org/" target="_blank">conventions</a>. It is the standard data format in oceanography and climatology. netCDF files are usually stored on servers with support for <a href="https://www.opendap.org/" target="_blank">opendap</a>. This means that users can either download the netCDF file and then open it locally, or use the opendap protocol to open it remotely. What that means is that you can do </div><div><br></div><div><font face="monospace">from netCDF4 import nc</font></div><div><font face="monospace">ds1 = nc.Dataset("<path to local file>")</font></div><div><font face="monospace">ds2 = nc.Dataset("<link to opendap address>")</font></div><div><br></div><div>and both ds1 and ds2 will behave identically. However ds2 is not downloaded locally, but rather read remotely on demand. If a file contains a 3D matrix (time, lat, lon), you can read one slice of the matrix without downloading it all. </div><div><br></div><div>Some of our pywps.Process support both netCDF file and opendap access. We define a ComplexInput for the address to an actual netCDF file, and a LiteralInput for the opendap address.</div><div><br></div><div>My question is whether there would be a clean way for pywps to support both modes with one ComplexInput? Internally, pywps would check if the address supports opendap (just check if nc.Dataset(url) works), and if not, would download the file locally to the server. </div><div><br></div><div>In both cases, we could do </div><div><br></div><div><font face="monospace">ds = nc.Dataset(requests.inputs['resource'][0].file)</font></div><div><font face="monospace"><br></font></div><div>I'm willing to put the time to do it, I just don't know where to start. </div><div><br></div><div>Thanks,</div><div><br></div><div>David</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div></div></blockquote></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
_______________________________________________<br>
pywps-dev mailing list<br>
<a href="mailto:pywps-dev@lists.osgeo.org" target="_blank">pywps-dev@lists.osgeo.org</a><br>
<a href="https://lists.osgeo.org/mailman/listinfo/pywps-dev" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/pywps-dev</a></blockquote></div><br clear="all"><br>-- <br><div dir="ltr" class="m_5169858571654734668gmail_signature" data-smartmail="gmail_signature">Jachym Cepicky<br>e-mail: jachym.cepicky gmail com<br>URL: <a href="http://les-ejk.cz" target="_blank">http://les-ejk.cz</a><br>GPG: <a href="http://les-ejk.cz/pgp/JachymCepicky.pgp" target="_blank">http://les-ejk.cz/pgp/JachymCepicky.pgp</a><br></div>
_______________________________________________<br>
pywps-dev mailing list<br>
<a href="mailto:pywps-dev@lists.osgeo.org" target="_blank">pywps-dev@lists.osgeo.org</a><br>
<a href="https://lists.osgeo.org/mailman/listinfo/pywps-dev" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/pywps-dev</a></blockquote></div>