Giter Club home page Giter Club logo

Comments (2)

judsoncrouch avatar judsoncrouch commented on August 25, 2024

Hi Joe,

I have used pynco successfully on Windows 10 a couple of times however when I try to initiate some operations, I get the same error. I am still relatively new to Python so I am not sure if this is an issue with my code or with pynco.

My code:

from nco import Nco 
import os

nco = Nco()

#Folder containing .nc files I want to loop through
folder = os.listdir("C:\\Users\\jcrouch\\Desktop\\HFRadar")

#Loop through each ncfile to set the record dmn
#and append "_time" to the end of the file name
print("Making record dimensions...")
for ncfiles in folder:
    files = ncfiles.strip()
    inputs = str(files)
    outputs = str(os.path.splitext(files)[0] + "_time.nc")
    print("Input file = " + inputs)
    print("Output file = " + outputs)
    print("\n")
    nco.ncks(input = inputs, output = outputs, mk_rec_dmn = 'time_run')
print("Record dimensions complete.")

The output:

Making record dimensions...
Input file = 08_12.nc
Output file = 08_12_time.nc

Error in calling operator ncks with:
C:\Downloads\nco\ncks --mk_rec_dmn=time_run --output=08_12_time.nc 08_12.nc <<<
Inputs: 08_12.nc
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 2. Translation into English with nc_strerror(2) is "No such file or directory"\r\n'
Traceback (most recent call last):
  File "C:\Users\jcrouch\Desktop\python\projects\nco\mk_rec_dmn.py", line 20, in <module>
    nco.ncks(input = inputs, output = outputs, mk_rec_dmn = 'time_run')
  File "C:\Program Files\Python35\lib\site-packages\nco-0.0.2-py3.5.egg\nco\nco.py", line 245, in get
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 2. Translation into English with nc_strerror(2) is "No such file or directory"\r\n'
[Finished in 0.3s with exit code 1]

If it is indeed my code (more than likely), how do you suggest looping through .nc files using pynco?

from pynco.

jhamman avatar jhamman commented on August 25, 2024

Good to hear that you have gotten pynco on windows. I suppose we can close this issue now.

As for your error, it seems like 08_12.nc isn't a file. Try using glob.glob instead of os.listdir
Running this should raise the same error:
C:\Downloads\nco\ncks --mk_rec_dmn=time_run --output=08_12_time.nc 08_12.nc

from pynco.

Related Issues (20)

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.