I noticed what I believe is a slightly odd behavior of the setFormatPattern method. While a format pattern is set on a visad.DateTime object, it gets applied globally in the jython shell.
Code: Select all
def testload(local=False):
"""
Returns a small set of addeParms to begin testing a file load. Additional
parameters can be added. This is done to speed testing.
Input:
local = boolean (default=False) -- determines whether or not a local
test dataset will be used. By default, parameters to match the
eastl server are returned.
"""
centerLocation = {'lat':39.8, 'lon':-103.8}
if (local):
visDataSet = getLocalADDEEntry(dataset=dataSet, imageType='Colorado VIS May21')
parmsS = dict(
localEntry=visDataSet,
unit='BRIT',
band=1,
mag=(1,1),
size=(200,200),
place=CENTER,
coordinateSystem=LATLON,
location=(centerLocation['lat'],centerLocation['lon'])
)
else:
parms = dict(
server='eastl.ssec.wisc.edu',
dataset='EASTL',
descriptor='CONUS',
band=2,
unit='TEMP',
mag=(1,1),
size=(200,200),
place=CENTER,
coordinateSystem=LATLON,
location=(centerLocation['lat'],centerLocation['lon'])
)
return parms
addeParam=testload()
data=loadADDEImage(**addeParam)
nominalTime1=data['nominal-time']
print 'Original date/time format from first loadADDEImage is {}'.format(nominalTime1.getFormatPattern())
print 'Original date/time is {}'.format(nominalTime1)
nominalTime1.setFormatPattern('YYYYddd HH:mm:ss z')
print 'Current date/time format from first loadADDEImage is now {}'.format(nominalTime1.getFormatPattern())
print 'Current date/time is {}\n'.format(nominalTime1)
print '****Load a second set of data****'
addeParam['position']=-1
data2=loadADDEImage(**addeParam)
nominalTime2=data2['nominal-time']
print 'Original date/time format from second loadADDEImage is {}'.format(nominalTime2.getFormatPattern())
print 'Second loadADDEImage date/time is {}'.format(nominalTime2)
print '\nIn jython shell, the format pattern is applied globally, overidding anything set in User Preferences rather than being local.\n'
print 'Do you get the same result?\n'
print 'Is there a reason for this, or is this a mistake?'
Could you run some version of the code to test this observation?
Thanks,
Joleen