> On Nov 11, 2010, at 1:54 PM, Chris Rebert wrote:
>> On Thu, Nov 11, 2010 at 1:16 PM, Neil Berg <nb...@atmos.ucla.edu> wrote:
>>> Hi Python community,
>>>
>>> In a main script, I pass the year (yr), month (mo), day (dy) and hour(hr) 
>>> into the utc_to_local function (pasted below) which converts that date and 
>>> time into local standard time.  I am passing several dates and times into 
>>> this function and would like to work with the "returned" loc_y/m/d/h values,
>>> but no output is visibly seen when I run the main script.
>>
>> Does the main script print() the returned values? Python doesn't
>> output stuff unless you explicitly ask it to (except when you're using
>> the REPL). Show us your main script, or at least the part of it where
>> utc_to_local() is called.
>>
>>>  I want the "return" command to just return the values to me in the main 
>>> script so I can work with them!
>>
>> It already does that. The problem must lie with the caller (i.e. the
>> main script).

On Thu, Nov 11, 2010 at 2:57 PM, Neil Berg <nb...@atmos.ucla.edu> wrote:
> My main script reads in monthly netCDF files that record variables each hour 
> for that month.  The length of all time variables is equal to the number of 
> hours per month.  Using January 1995, for example, time_y is a 1d array of 
> the integer 1995 repeated 744 times, time_m is a 1d array of the integer 1 
> repeated 744 times, time_d is a 1d array that ranges from 1 to 31, and time_h 
> is a 1d array that cycles from 0 23.  The part that calls upon utc_to_local() 
> is:
>
> time_y = ncfile.variables['time_y'][:] # (time,int) [yrs]
> time_m = ncfile.variables['time_m'][:] # (time,int) [mnths]
> time_d = ncfile.variables['time_d'][:] # (time,int) [days]
> time_h = ncfile.variables['time_h'][:]    # (time,float) [hrs]
> ntim =len(time_h)
> for tim_idx in range(0,ntim):
>        local_date = 
> utc_to_local(time_y[tim_idx],time_m[tim_idx],time_d[tim_idx],int(time_h[tim_idx]))
>        ***Here is where I'd like to see the returned values so I can create 
> new arrays that store them *****

Add:
    print(local_date)
Or if you want to be fancy:
    print("%.4d-%.2d-%.2d  %.2d" % local_date)

Cheers,
Chris
--
http://blog.rebertia.com
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to