Giter Club home page Giter Club logo

pynco's Introduction

NCO NetCDF Operators

The NCO toolkit manipulates and analyzes data stored in netCDF-accessible formats, including DAP, HDF4, and HDF5. It exploits the geophysical expressivity of many CF (Climate & Forecast) metadata conventions, the flexible description of physical dimensions translated by UDUnits, the network transparency of OPeNDAP, the storage features (e.g., compression, chunking, groups) of HDF (the Hierarchical Data Format), and many powerful mathematical and statistical algorithms of GSL (the GNU Scientific Library). NCO is fast, powerful, and free.

What is NCO?

The netCDF Operators (NCO) comprise a dozen standalone, command-line programs that take netCDF, HDF, and/or DAP files as input, then operate (e.g., derive new data, compute statistics, print, hyperslab, manipulate metadata) and output the results to screen or files in text, binary, or netCDF formats. NCO aids analysis of gridded scientific data. The shell-command style of NCO allows users to manipulate and analyze files interactively, or with expressive scripts that avoid some overhead of higher-level programming environments.

Traditional geoscience data analysis requires users to work with numerous flat (data in one level or namespace) files. In that paradigm instruments or models produce, and then repositories archive and distribute, and then researchers request and analyze, collections of flat files. NCO works well with that paradigm, yet it also embodies the necessary algorithms to transition geoscience data analysis from relying solely on traditional (or “flat”) datasets to allowing newer hierarchical (or “nested”) datasets.

Operator Full Name Examples
ncap2 netCDF Arithmetic Processor here
ncatted netCDF ATTribute EDitor here
ncbo netCDF Binary Operator here
ncclimo netCDF CLIMatOlogy Generator here
nces netCDF Ensemble Statistics here
ncecat netCDF Ensemble conCATenator here
ncflint netCDF FiLe INTerpolator here
ncks netCDF Kitchen Sink here
ncpdq netCDF Permute Dimensions Quickly, Pack Data Quietly here
ncra netCDF Record Averager here
ncrcat netCDF Record conCATenator here
ncremap netCDF REMAPer here
ncrename netCDF RENAMEer here
ncwa netCDF Weighted Averager here

How to Contribute: Volunteer, Endorse, or Donate

The NCO project homepage points to mailing lists, discussion forums, and instructions to make contributing easy.

Acknowledgements

NCO has been supported by volunteers and professionals since 1995. External support from DOE, NASA, and NSF has sustained development and addition of its most powerful features.

pynco's People

Contributors

czender avatar hmb1 avatar kwilcox avatar lukelbd avatar monocongo avatar mx-moth avatar saveriogzz avatar suizer98 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pynco's Issues

Use of subprocess with shell=True, security vulnerability?

nco.py lines 108 and 336 uses shell=True which is advised against in the Python documentation. Could this be updated to use shell=False without affecting anything? Is the use of the spawned shell in these cases in order to get access to (assumed) shell functionality that's not easily provided within Python? I'm not sure if this is an actual issue or not for pynco itself, but it's preventing my usage of pynco in a work project due to this known security concern. If it's not too much work to modify this without breaking anything then I'm game to give it a whirl, but can somebody who knows please comment if the shell=True is in place for good reason, so I won't bark up the wrong tree if that's the case?

Error : pynco in Windows10

Hi there,
I am using anaconda and used the command:
conda install -c conda-forge pynco
to install pynco in my Windows10 machine and simply used the commands
from nco import Nco
nco = Nco()

I get the error below. Will appreciate help to resolve the issue.

TypeError Traceback (most recent call last)
in ()
1 from nco import Nco
----> 2 nco = Nco()

~\Anaconda3\lib\site-packages\nco\nco.py in init(self, returnCdf, returnNoneOnError, forceOutput, cdfMod, debug, **kwargs)
52 self.NCOpath = os.environ['NCOpath']
53 else:
---> 54 self.NCOpath = os.path.split(which('ncks'))[0]
55
56 self.operators = operators

~\Anaconda3\lib\ntpath.py in split(p)
202 Return tuple (head, tail) where tail is everything after the final slash.
203 Either part may be empty."""
--> 204 p = os.fspath(p)
205 seps = _get_bothseps(p)
206 d, p = splitdrive(p)

TypeError: expected str, bytes or os.PathLike object, not NoneType

Unknown operator: ncdump

Where is ncdump?
Please correct me if I'm wrong.
ncdump is the first troubleshooting command on the documentation and apparently it is not there in the nco class.

Best,
Michele

concatenating variables from multiple netCDF files does not work

Hi, Joe

Recently, I found pynco and tried it in my work. But It seems nco.ncrcat does not work properly.

infile = glob.glob('b.e13.Bi1850C5.f19_g16.21ka.06.test.cam.h0.026*.nc')
nco.ncrcat(input=infile,output="TS.nc",v="TS",debug=True)

No TS.nc file was created.
Any suggestions?

Sort out `pynco` vs. `nco` on PyPI

This project goes under a few names in different places, and the differences are confusing some users.

  • The repository is called pynco
  • It uses the nco programs
  • The Python package is published as nco on PyPI. The documentation instructs users to pip install nco
  • There is also a package named pynco on PyPI, owned by the maintainers of this project, but has not been updated since 2015
  • The package is named pynco on conda-forge
  • nco on conda-forge is the nco programs that this project binds to
  • The Python module that users import is called nco

The project should settle on using either pynco or nco, but not both. As nco is an established project that this project binds to, my vote is to settle on pynco. To move everything to pynco the following steps would be required:

  • Call the package pynco on PyPI
    • Update the package name in the package metadata
    • Update the README and documentation to instruct used to install the correct package
    • Release version 2.0.0 of pynco to PyPI
    • Deprecate the nco PyPI package
  • Rename the Python module to pynco
    • Update the documentation to reflect this change
    • Add a backwards compatibility nco import, with a deprecation warning. Two options:
      • Ship two modules in the package, nco and pynco. Importing nco would raise a DeprecationWarning but otherwise be an alias for the correct pynco module.
      • The pynco PyPI package only provides the pynco module. The nco PyPI package provides the nco module which depends on pynco. When a user calls import nco a deprecation warning is raised instructing users to move to pynco.

ncks "append mode" is broken

The code to retrieve the version of NCO is currently broken:

  File "/home/kwilcox/miniconda3-py36/envs/packrat35/lib/python3.5/site-packages/nco/nco.py", line 224, in get
    nco_version = self.version()
  File "/home/kwilcox/miniconda3-py36/envs/packrat35/lib/python3.5/site-packages/nco/nco.py", line 364, in version
    ncra_help)
  File "/home/kwilcox/miniconda3-py36/envs/packrat35/lib/python3.5/re.py", line 173, in search
    return _compile(pattern, flags).search(string)
TypeError: cannot use a string pattern on a bytes-like object

When specifying the append flag (-A) in ncks, the version() function is called resulting in errors. We need some test coverage for the append ncks functionality!

$ python
Python 3.5.3 | packaged by conda-forge | (default, Feb  9 2017, 14:37:12) 
[GCC 4.8.2 20140120 (Red Hat 4.8.2-15)] on linux

options

Curious how one gets the options input to work for ncks.

My verified command-line code:
ncwa -C -a lat,lon,time -d lon,-105,-100 -d lat,30,35 -l /tmp -p http://some.thredds.server/thredds/in.nc ~/out.nc

My pynco command (run from python 3.7)
nco.ncks( input = URLnc, output = Otmp, options = [ c.Limit("lat", minLt, maxLt), c.Limit("lon", minLn, maxLn) ])

The error:

NameError: name 'c' is not defined

This is a rather obvious error, but the examples that I'm following on your page do not elaborate on the functionality here. I'm sure this is trivial.

Ultimately, what I want to do is extract netcdf information from a given lat,lon using NCO limits feature. Ideally I want to put this into pandas dataframe for quantitative analysis and time-series display.

Any help is appreciated.

Read The Docs integration is broken

Documentation for pynco is hosted on Read The Docs, but a new version has not been built in over four years. This implies that the integration is broken. This also means that the documentation hosted on read the docs is out of date.

Either the integration should be fixed, or the out-of-date documentation taken down.

In service of this, I've made two branches. Assuming that the read the docs integration can be restored, I've made a docs branch that updates index/docs.md and links to this documentation from the README. If the integration can not be fixed, I've made a readme branch that removes the docs and moves all documentation to the README.

@czender @hmb1 @jhamman Does anyone have access to the pynco Read The Docs project?

Error calling NCO command with tempfile helper

I am attempting to use the Python NCO bindings for calling an NCO command using the tempfile helper feature. For example:

nco = Nco()
temp_netcdf_file = nco.ncpdq(input=arguments.netcdf_precip,
                             options=["-a \"-lat,lon,time\""])

My expectation from the above is that I will receive a string value with the name of the temporary NetCDF file created as a result of the NCO command. (Or maybe it will be a file object? The return type for this usage is unclear from the documentation.)

When I run the above I get an error:

nco.nco.NCOException: (returncode:1) b''

When I step through the nco.py code I see the command appears to be properly parsed:

cmd: <class 'list'>: ['/home/james/miniconda3/envs/climate/bin/ncpdq', '-a', '"-lat,lon,time"']

However, when the command is called (line 263) it gets unexpected return values, resulting in the above-mentioned exception.

I can run the command in a terminal on Linux (Ubuntu 18.04) without issue, although in that case I am specifying an output file.

I have seen similar behavior the previous time I attempted to use this package, perhaps these two issues are related?

Thanks in advance for any help with this.

Merge netcdf4 files: same variables, different time series (PyNCO)

(PyNCO question posted on behalf of a user who does not know about github and PyNCO)

Hi,
I am trying to merge netcdf4 files that have the same variables within the files but different time series. I have downloaded the NCO package and trying to merge the files using ncrcat. I am using spyder(python) to read the netcdf4 files. I have done the following but then am confused as to how to write the command.

from nco import Nco
nco = Nco()

from netCDF4 import Dataset

file4 = Dataset('C:/test4.nc4')
file3 = Dataset('C:/test3.nc4')

I know that in order to combine the 2 files, ncrcat must be used in such a manner:
ncrat file1.nc file2.nc fileoutput.nc

but I am unsure of how to execute this command based on my input files. Any assistance on this matter would be greatly appreciated.
Kind regards,
Tasha

Pip install incomplete

Hi

I tried to get nco.ncatted working where I installed the package using pip but it didn't work. I've set out how I fixed it below and what needs to be done to solve the issue generally.

Firstly, the pip install didn't include the custom.py file, so python didn't recognise the c.Atted object in this command: nco.ncatted(input="in.nc" options=[ c.atted("overwrite","_FillValue","three_dmn",-9.91e+33,'d')])

Once I added the custom.py file to my nco folder the command still didn't work. The github code seemed to have extra stuff around line 102, so I replaced the pip file with the github file and everything worked perfectly.

Can someone: add the custom.py file to the pip package; update the pip package to the new github nco.py file; and add the line 'from nco import custom as c' to the user instructions on https://github.com/nco/pynco

Thanks for building the package!
Liam

outputOperators with multiple meanings

Since NCO version 4.3.7, output operators -H, -M, and -m have dual meanings depending on whether or not -A is specified. "When copying/subsetting/appending files (as opposed to printing them), the copying of data, variable metadata, and global/group metadata are now turned OFF by -H, -m, and -M, respectively." (https://sourceforge.net/p/nco/discussion/9830/thread/0fdc1d1e/).

However, pynco checks for these output operators to determine whether the output prints out to the screen lines 208-212. In that case, the output file is not appended to the cmd before the function call at line 215. The result is that the -A flag and its alternate uses are ignored. This can be fixed by adding a check for -A in the definition of operatorPrintsOut in lines 208-212.

Initializing `Nco` with `overwrite=True` causes indefinite hang

Using Nco(overwrite=True) causes an indefinite hang due to triggering a user-input prompt when subequently calling an nco command. Here's a simple example (see the attachment file):

from nco import Nco
nco = Nco(overwrite=True)
nco.ncatted(input='tmp.nc', output='tmp.nc', options=['-a foo,ts,o,c,bar'])

tmp.zip

I tried printing print(' '.join(cmd)) before the following line:

pynco/nco/nco.py

Lines 332 to 334 in e17172c

retvals = self.call(
cmd, inputs=input, environment=environment, use_shell=use_shell
)

and the result was ncatted -a ts,foo,o,c,bar --overwrite --overwrite --output=tmp.nc. When I enter this in the command line after adding inputs with ncatted -a ts,foo,o,c,bar --overwrite --overwrite tmp.nc --output=tmp.nc I get the prompt:

(base) enceladus[1]:tmp$ ncatted -a ts,foo,o,c,bar --overwrite --overwrite tmp.nc --output=tmp.nc
ncatted: overwrite tmp.nc (y/n)?

So it seems a double overwrite flag triggers the input prompt, causing the infinite hang. I realize now overwrite=True isn't necessary since Nco(force_output=True) is the default, but this was hard to debug / could be a problem for others.

m

@jhamman
@czender

HI Joe its been a while since I've looked at pynco with python3.
Users have raised a few issues which I have addressed

  1. ncks - Shell commands not working at all
    fixed this by setting use_shell=True by default in get()

  2. Some of the option args to ncap2 need to be enclosed with single or double quotes
    shlex.split was removing these quotes
    fixed by using the original
    cmd.extend(str.split(option))

  3. The nco operators ncks, ncatted, ncap2, ncrename can function with a single input file and
    have no need of a temporary file. Have addressed this by making a list of these
    self.SingleFileOperatorsPattern = ["ncap2" , "ncatted", "ncks", "ncrename"]

I have my mods on a branch on my local machine.
How do you wish to proceed ?
Can you give me write permission to the repo so I post my branch ?
OR do you wish me to create a fork ?

Many thanks
....Henry

'Rename' object not iterable

I am unable to successfully use the nco.ncrename command using pynco 1.0 with nco 4.8.2 on Linux. The error is:

File "/home/arcgis/arcgis/miniconda3/envs/arcpython/lib/python3.6/site-packages/nco/nco.py", line 210, in get cmd.extend(option)
TypeError: 'Rename' object is not iterable

Here is the code I am using:

        for name in ['dimension', 'variable']:
            rDict = param['names'][name]
            nco.ncrename(input=nc_file, options=[Rename(name, rDict)])

Am I doing something wrong or is there a bug? I have no problems renaming when using nco directly from the terminal.

Thanks!

c.Rename not defined

Hi,

I'm trying to rename all vars and dims in a set of netcdf files and wanted to use Python to achieve this. I found pynco and used your sample code for renaming.

os.chdir('/g/data/rr9/IM_PhD/data/test_download/latlon_fix/MU-CLIM/')

nco = pynco.Nco()
rDict = {
    'latitude': 'lat',
    'longitude': 'lon'
}
for fname in glob('*.nc'):
    nco.ncrename(input=fname, options=[ c.Rename("variable", rDict) ])

However it comes up a 'NameError: name 'c' is not defined'. I'm not a Python guru so thought my code might be off, but can you confirm? The docs make no mention of defining a 'c' object.

Cheers
Ian

inscrutable error message on non-root install

Hi Joe,
Inadvertently tried "pip install nco" without sudo priveleges and got this inscrutable error:

  Running setup.py install for nco
    Complete output from command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-build-e5y0QK/nco/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-1Y7oV2-record/install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    creating build
    creating build/lib
    creating build/lib/nco
    copying nco/__init__.py -> build/lib/nco
    copying nco/nco.py -> build/lib/nco
    running install_lib
    creating /usr/lib/python2.7/site-packages/nco
    error: could not create '/usr/lib/python2.7/site-packages/nco': Permission denied

    ----------------------------------------
Command "/usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-build-e5y0QK/nco/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-1Y7oV2-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-e5y0QK/nco

Then tried with sudo and everything went fine:

zender@givre:/data/zender/sld/raw$ sudo pip install nco
Collecting nco
  Downloading nco-0.0.2.tar.gz
Installing collected packages: nco
  Running setup.py install for nco
Successfully installed nco-0.0.2

Is it possible to print a more humanly readable error message for install attempts with wrong permissions?
Thx,
c

Atted object passes quotation marks as part of var_name and att_name to subprocess

This may be a 'me' problem, but I have found that when using the Atted object, the nco.ncatted command fails. This is, as far as I can see, due to the return value of the Atted object being formatted as

return '-a "{0}","{1}",{2},{3},{4}'.format(
            self.att_name, self.var_name, self.mode, type_char, strvalue
        )

which results in an error message saying something along the lines of 'no variable named "time" found'.

As an example, running the following script will fail:

from nco.custom import Atted
from nco import Nco

nco=Nco()
ifile = /path/to/input/file
ofile = /path/to/output/file

att_val = -999
var = "time"
att = "_FillValue"
att_type="i"

opts=[Atted(mode="modify",att_name=att,var_name=var,value=att_val,stype=att_type)]

nco.ncatted (input=ifile, output=ofile, options=opts)

The error message it will state that the call attempted would be

/usr/bin/ncatted -a "_FillValue","time",m,i,-999 --output=/path/to/output/file /path/to/input/file

which if run directly in the terminal will execute correctly.

From what I can see, it seems that when the string is passed to subprocess.Popen, the quotation marks are preserved in the string, and so the variable name and attribute names are read by ncatted as including the quotation marks. I have confirmed this by trying to run the above string as

subprocess.run(ncatted_string.split())

which gives the same error.

If instead of using the Atted object I call nco.ncatted with the option string

opts = [" -a {0},{1},m,{2},{3}".format(att, var, att_type, att_val)]

then the call works correctly, and so the issue seems to be only with the Atted object in nco.custom.

I cannot personally confirm whether this is also an issue with the Limit, LimitSingle or Rename objects as I have only been using ncatted, however a quick look at the prn_option functions in these classes shows quotation marks similar to those in the prn_option function for Atted, and so a similar error may occur for these also.

I encountered this error using pynco 1.0.0

Drop python 2?

Most scientific python libraries have already dropped or are in the process of dropping Python 2. Should we do that now in pynco?

Use netcdf4 module as the default cdfMod

A few points here:

  • the scipy module is now pretty old and lags behind the netcdf4 module
  • most of us are using the netcdf4 module which is readily available and easy to install.
  • Currently there is some behind the scenes error handling that is less than desirable.

Future releases should include the netcdf4 module as the default.

Enable read_array function to return multiple arrays

I am modifying the read_array function inside nco.py as below:

   def read_array(self, infile, var_names):
        file_handle = self.read_cdf(infile)

        for var_name in var_names:
            try:
                # return the data array for each variable
                result[var_name] = file_handle.variables[var_name][:]
            except KeyError:
                print("Cannot find variable: {0}".format(var_name))
                raise KeyError

        return result

The usage for my case would be:

variables = ["longitude", "latitude", "time"]
result = nco.ncks(
    input="sample.nc", options=["-v " + ",".join(variables)], returnArray=variables
)

lon = result["longitude"][:]
lat = result["latitude"][:]
...

so we don't have to call returnArray=[] one by one.
I remember the native nco commands extract multiple variables such as:
ncks -v latitudes,longitudes
can support extracting multiple variables from netcdf file.
If this kind of actual feature is already existed, feel free to address how should I use/call it, in case I missed it.

Use a more permissive license?

Currently pynco is licensed under GPL2. I am leaning toward changing this to a more permissive license such as MIT. I'm wondering if others (specifically @kwilcox @monocongo or @czender) have specific thoughts on how this may impact their use of the code.

Consider renaming the package

Hi, I know that this is a terrible suggestion! However, since the package is in its earlier stages maybe renaming it is not a big problem.

If you call the package nco it will create a confusing for packagers. If you call it nco-bindings it is not very descriptive since it is about python bindings only.

I saw that you had NCOpy in the first release. I like that, or infact anything similar like: python-nco, pynco, etc. (Not ncopy though, that will read: n_copy 😉)

Note that the module and how we import it does not have to change.

Thanks for the binding BTW!

Permission denied error using pynco ncks on windows

Hello,
I am a beginner in Python and a new user of pynco. I am trying to write a small scripts that reads through a directory and creates a spatial subset of each file. The last command raises and error related to permissions. However, when I check the folder where the output files should be saved, I see that these have been generated, and when opened they seen alright. Does anyone have an idea of what the issue might be?
Here is my script:

import os
from nco import Nco
from nco import custom as c
nco = Nco()

in_dir = r"D:\02_Portfolios\01_CCCM_Shelter\06_NaturalHazards\01_TropicalCyclones&StormSurge\ERA5-INTERIM"
out_dir = r"D:\02_Portfolios\01_CCCM_Shelter\06_NaturalHazards\01_TropicalCyclones&StormSurge\Work\outputs" 
os.chdir(in_dir)
path = os.getcwd()

# Create a subset of the NetCDF files
opt = [
        c.Limit(dmn_name="longitude", srt=42.304738, end=78.091223).prn_option(),
        c.Limit(dmn_name="latitude", srt=-11.534835, end=20.098029).prn_option()]
		
for f in os.listdir(path):
    f_split = os.path.split(f)[1]
#    iname = os.path.join(in_dir,f)
    out_f = os.path.join("temp",f_split.split('.')[0] + "_NorthIndian.nc")
    subset = nco.ncks(input=f, output=out_f, options=opt)

and this is the error I get:

Error in calling operator ncks with:
>>> C:\Users\reach\anaconda3\Library\bin\ncks -d longitude,42.304738,78.091223 -d latitude,-11.534835,20.098029 --output=temp\temp_NorthIndian.nc temp <<<
Inputs: temp
b'nco_err_exit(): ERROR Short NCO-generated message (usually name of function that triggered error): nco__open()\r\nnco_err_exit(): ERROR Error code is 13. Translation into English with nc_strerror(13) is "Permission denied"\r\n'
Traceback (most recent call last):
  File "D:\02_Portfolios\01_CCCM_Shelter\06_NaturalHazards\01_TropicalCyclones&StormSurge\Work\TropicalCyclones\Python\WindSpeed.py", line 21, in <module>
    subset = nco.ncks(input=f, output=out_f, options=opt)
  File "C:\Users\reach\anaconda3\lib\site-packages\nco\nco.py", line 342, in get
    raise NCOException(**retvals)
nco.nco.NCOException: (returncode:1) b'nco_err_exit(): ERROR Short NCO-generated message (usually name of function that triggered error): nco__open()\r\nnco_err_exit(): ERROR Error code is 13. Translation into English with nc_strerror(13) is "Permission denied"\r\n'

Thank you very much in advance for your help!

Source tarball on PyPI is missing tests/conftest.py

The source tarball for the latest version 1.1.2 (but also for previous versions) does contain tests/test_nco.py and tests/test_nco_examples.py, but not tests/conftest.py. This makes the tests unusable, since required fixtures defined in conftest.py are missing. I am not sure if there might be other necessary files missing as well.

Conda-forge instead of ioos?

Is the ioos channel that PyNCO uses completely compatible with conda-forge or might it cause path/library issues? Does it make sense to shift PyNCO from ioos to conda-forge? I'm hazy on the details of compatibility between conda-forge and ioos channels.

The conda-forge NCO package was recently (~April) updated to include ESMF_RegridWeightGen for use by ncremap. This makes the conda-forge package very appealing, and it would seem make sense to have both NCO and PyNCO on the same channel...

NCO error

Hi,
I have installed NCO on Spyder(Python) yet when I attempt to use it, it prints out a list of errors. I am using windows, and installed NCO using pip in the command prompt; it installed nco-0.0.2.tar.gz.

This is the error that it prints:

File "", line 1, in
runfile('E:/python/spyder/ncotest.py', wdir='E:/python/spyder')

File "C:\Users\211540119\Documents\Masters\Hycom\WinPython-64bit-2.7.10.2\python-2.7.10.amd64\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 685, in runfile
execfile(filename, namespace)

File "C:\Users\211540119\Documents\Masters\Hycom\WinPython-64bit-2.7.10.2\python-2.7.10.amd64\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 71, in execfile
exec(compile(scripttext, filename, 'exec'), glob, loc)

File "E:/python/spyder/ncotest.py", line 9, in
nco = Nco()

File "C:\Users\211540119\Documents\Masters\Hycom\WinPython-64bit-2.7.10.2\python-2.7.10.amd64\lib\site-packages\nco\nco.py", line 52, in init
self.NCOpath = os.path.split(which('ncks'))[0]

File "C:\Users\211540119\Documents\Masters\Hycom\WinPython-64bit-2.7.10.2\python-2.7.10.amd64\lib\ntpath.py", line 180, in split
d, p = splitdrive(p)

File "C:\Users\211540119\Documents\Masters\Hycom\WinPython-64bit-2.7.10.2\python-2.7.10.amd64\lib\ntpath.py", line 115, in splitdrive
if len(p) > 1:

TypeError: object of type 'NoneType' has no len()

I am confused as to whether I have installed NCO properly or the correct version.
Any help on this issue would be greatly appreciated.

Kind regards,
Tasha

libnetcdf.so.7: cannot open shared object file: No such file or directory

Hi,

I am trying to run pynco on my debian machine, on a Conda environment.
I installed it by doing "conda install -c conda-forge pynco", but when I try to run some commands (such as "temperatures = nco.ncra(input=ifile, returnArray='T')", one of your examples), I get the following error:
/home/xxx/miniconda2/envs/python_env/bin/ncra: error while loading shared libraries: libnetcdf.so.7: cannot open shared object file: No such file or directory

When I do "ls /home/xxx/miniconda2/envs/python_env/lib", I have the following libnetcdf libs:
libnetcdf.a libnetcdf.settings libnetcdf.so libnetcdf.so.13

here are the details about my install
Current conda install:

           platform : linux-64
      conda version : 4.3.29
   conda is private : False
  conda-env version : 4.3.29
conda-build version : not installed
     python version : 2.7.14.final.0
   requests version : 2.18.4

Thank you!

Windows support

Over the years, a number of users have reported problems using pynco on windows. I don't have a windows machine nor do I have any use for this library in a windows environment. That said, if someone wanted to add test support and any associated fixes, I'd be happy to accept a PR in this area.

xref: #15 #36

ImportError: No module named custom

Hi,

I am trying to include NCO commands into my Python scripts through Pynco package.

I started to do some tests with basic manipulations of Netcdf files. Trying with "nco.rename" I used the syntax suggested in the WIki, i.e.:

rDict = {
    '.x': 'lon',
    '.y': 'lat'
}
nco.ncrename(input="tlcl.nc", options=[ c.Rename("tlcl", rDict) ])

But it returns an error saying that there is no global name called "c". I also tried to drop "c", but I got the same error with "Rename".

I read here (#30) that a module "custom" has to be imported. The question is, how to include it? The way it is suggested above gives me error:
"ImportError: No module named custom"

Is there a specific package that has to be included into the repository in order to obtain module "custom"?

Thanks in advance for the answer.

Best,

Valerio Lembo

Support using pynco on Windows

I've received a few questions about how to use pynco on Windows. I've never tried this but if anyone has, that would be great to hear. Otherwise, I'm going to leave this as an open issue until somebody wants to give it a try.

initialization issue

recieveing an issue in my django app on initialization
from nco import Nco
nco = Nco()

File "/**/***/***.py", line 46, in mergeDailyFile
    nco = Nco()
  File "/**/***/***/env/lib/python3.8/site-packages/nco/nco.py", line 58, in __init__
    self.nco_path = os.path.split(distutils.spawn.find_executable("ncks"))[0]
  File "/usr/lib/python3.8/posixpath.py", line 103, in split
    p = os.fspath(p)
TypeError: expected str, bytes or os.PathLike object, not NoneType

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.