Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Note that the meta-data for each field is taken from the first field in each subtraction; "step9 minus step6" returns a field with meta-data from step9, so be aware of this. Macro has functions for setting GRIB meta-data if you need to change it in order to correctly describe the new data.

Dates in Macro

Macro has specific date-handling abilties. Dates are a built-in data type which in fact describe both a date and a time.

Defining dates

You can create date variables in a number of ways:

  • yyyy-mm-dd
  • yyyy-DDD  (DDD is a 3-digit Julian day, e.g. 365 is 31st December in non-leap years)

These will have the time set to 00:00. A different time can be added by adding

  • HH:MM
  • HH:MM:SS

Create a new Macro icon, rename it to dates and define a date:

Code Block
languagepy
d = 2015-03-11
print(type(d))
print(d)

Try adding a time:

Code Block
d = 2015-03-11 09:00

Converting numbers into dates

The date() function converts numbers into dates using the same syntax that MARS understands. For example:

  • d1 = date(20150105)
  • today = date(0)
  • yesterday = date(-1)

Again, the time will be 00:00 unless we add it. We can consider the time to be a fraction of a day:

  • midday = date(20150105.5)