date conversions

How do I...?
User avatar
joleenf
Posts: 1123
Joined: Mon Jan 19, 2009 7:16 pm

date conversions

Post by joleenf »

Is there anything already coded in McIDAS-V which performs date conversions easily? I am looking for something like DATELIST (from McIDAS-X), which when entered at the command line, the current day would be returned in CCYYDDD and day full_month_name year and YYYY/MM/DD formats. Also, a date could be entered to get the julian date returned or a date offset from the current date.

Joleen
User avatar
barryr
Posts: 213
Joined: Thu Jan 08, 2009 5:42 pm
Contact:

Re: date conversions

Post by barryr »

Hi Joleen,
I'm told that there's no way to list different date formats (like the McIDAS-X command DATELIST). But there is a User Preference that lets you change the date format that appears in McV output (e.g., the layer label when you display an image). It's described here:

http://www.ssec.wisc.edu/mcidas/doc/mcv ... ences.html

Does that help?

Barry
User avatar
hproe
Posts: 504
Joined: Sat Nov 27, 2010 3:46 pm

Re: date conversions

Post by hproe »

Hi Joleen -

If you don't know. You may override whatever is specified in the Preferences wherever you can use the %timestamp%. E.g. when saving time sequence of frames with View>Capture>Movie... I specify in the Filename Template: %time:yyyyMMddHHmm% in order to get compact filenames while I am using the %timestamp% macro as specified through Preferences (in my case "yyyy-MM-dd HH:mmz") for more readable layer labels.

HP
User avatar
joleenf
Posts: 1123
Joined: Mon Jan 19, 2009 7:16 pm

Re: date conversions

Post by joleenf »

Actually, because there is the conversion option in the User Preferences and the conversion is also handled when pulling data from the archive that I thought there might be something already hidden within McIDAS-V that is similar.

Joleen
User avatar
tomw
Posts: 296
Joined: Tue Dec 23, 2008 3:40 pm

Re: date conversions

Post by tomw »

You can most easily use the Calendar class from Java...here's a little Jython:

>>> from java.util import Calendar
>>> cal = Calendar.getInstance()
>>> cal.set(2011,1,24)
>>> print cal.get(Calendar.DAY_OF_YEAR)
55

Note that months are Jan=0, Feb=1,...
User avatar
joleenf
Posts: 1123
Joined: Mon Jan 19, 2009 7:16 pm

Re: date conversions

Post by joleenf »

Great! This is what I was looking for!

Joleen
User avatar
joleenf
Posts: 1123
Joined: Mon Jan 19, 2009 7:16 pm

Re: date conversions

Post by joleenf »

Please refer to the printDate forum post to obtain updated date conversion functions. printDate replaces dateList and fixes some bugs in the old dateList code. If you are still using dateList, please replace it with the new printDate code.

viewtopic.php?f=32&t=1562
Last edited by joleenf on Thu Mar 19, 2015 3:08 pm, edited 1 time in total.
User avatar
joleenf
Posts: 1123
Joined: Mon Jan 19, 2009 7:16 pm

Re: date conversions

Post by joleenf »

Small change to the code.

The lines

# Force the user to enter year, jday and day as integers.
year, jday, day=int(year), int(jday), int(day)

should include the "inc" variable as well...

# Force the user to enter year, jday and day as integers.
year, jday, day, inc=int(year), int(jday), int(day), int(inc)
User avatar
joleenf
Posts: 1123
Joined: Mon Jan 19, 2009 7:16 pm

Re: date conversions

Post by joleenf »

pd is now included in the printDate code, located in the following forum post:

viewtopic.php?f=32&t=1562

pd is shorthand for printDate. pd will quickly print the date for an input date, but does not provide any option for output date format. After copying the code found in the forum post viewtopic.php?f=32&t=1562, please use

testPrintDate() # to test printDate code
progHelp(pd) # to display help for the updated pd function
progHelp(printDate) # to display help for updated date conversion function.
Last edited by joleenf on Thu Mar 19, 2015 3:11 pm, edited 1 time in total.
User avatar
joleenf
Posts: 1123
Joined: Mon Jan 19, 2009 7:16 pm

Re: date conversions

Post by joleenf »

See above. dateList has been replaced by printDate.
Last edited by joleenf on Thu Mar 19, 2015 3:11 pm, edited 1 time in total.
Post Reply