[Tutor] Assessing local variable outside function

nils wagenaar nilswagenaar at hotmail.com
Thu Oct 27 21:38:29 EDT 2016


Hello,


Could i use a variable defined in a function in another function?

I have now:


def DatasetToSubset(file, LatUpbound, LatLowBound, LonUpBound, LonLowBound):
     nc=netCDF4.Dataset(file)
     lats=nc.variables['lat'][:]; lons=nc.variables['lon'][:]
     latselect=np.logical_and(lats > LatLowBound, lats < LatUpBound)
     lonselect=np.logical_and(lon > LonLowBound, lon < LonUpBound)
     data=nc.variables['Runoff'][1000, latselect, lonselect]
     return data; return latselect; return lonselect


So, i want to use latselect and lonselect in a different function where i interpolate for the subsetted area.


Nils


More information about the Tutor mailing list