error

jorge.conrado at cptec.inpe.br jorge.conrado at cptec.inpe.br
Wed Sep 2 20:18:43 CEST 2015


Hi,


I have a Python version: Python 2.7.8

I'm runing it on: Fedora release 21


Yesterday I a sent a question:


I'm starting in the Python scripts. I run this script:


import numpy as np

import netCDF4

f = netCDF4.Dataset('uwnd.mon.ltm.nc','r')


f.variables


and I had the message:


netcdf4.py
Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
NameError: name 'netcdf4' is not defined


I had two answers to my question. But I could not understand them. I 
don't have expericence with Python. So I downloaded from the Web a code 
to calcluate the dew point temperature:


import sys
import numpy as np

# approximation valid for
# 0 degC < T < 60 degC
# 1% < RH < 100%
# 0 degC < Td < 50 degC

# constants
a = 17.271
b = 237.7 # degC

# sys.argv[0] is program name
T=float(sys.argv[1])
RH=float(sys.argv[2])


def dewpoint_approximation(T,RH):

     Td = (b * gamma(T,RH)) / (a - gamma(T,RH))

     return Td


def gamma(T,RH):

     g = (a * T / (b + T)) + np.log(RH/100.0)

     return g


Td = dewpoint_approximation(T,RH)
print 'T, RH',T,RH
print 'Td=',Td


Then I run it and I had the message:

             p2.py


Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
NameError: name 'p2' is not defined


Like the same error that I had for my first run.

Please, someone can help me. I have a commercial software and I would 
like to use Python.

In advance. Thanks,

Conrado



More information about the Python-list mailing list