Recent Improvements to Kalpana

This post was contributed by CCHT collaborator Jason Fleming. He revised the Kalpana script to improve its efficiency and utility.

In the process of working on Kalpana, one of the deliverables was to clean the code, where possible. The following improvements were made as part of this deliverable.

  • Implement command-line options to replace the interactive menu driven interface.
  • Allow the user to specify the file name separately from the file type, while keeping the default file name the same as the file type.
  • Enable the use of a custom logo in the kmz, to control its size either as a fraction of the display size or in pixels; and to completely omit the logo overlay.
  • Generalize the handling of different file types, including differences between the handling of time-varying output and the processing of min/max files, using python dictionaries.
  • Support for conversion to English units (e.g., ft instead of meters) via command line options instead of hard coding.
  • Automate the previously hard-coded labeling for the color scale, including the appropriate units.
  • Allow the user to specify the datum for use in labeling the color scale.
  • Add support for user-defined color scales using palette files.
  • Specify tick labels on the color bar on the command line, rather than always using the contour levels, which may cause issues when the contour levels are not evenly spaced (e.g., the blue-green bathy/topo color scale).
  • Enable user to specify the contour levels, either as a range of values and an increment, or to directly specify the individual contour levels to replace the hard coded contour levels for each data type.
  • Fix issue where the contour values themselves were not being used to interpolate the colors of the contours; the number of contour levels was used and the code assumed they were evenly spaced. The issue was corrected so that the actual contour values are now used to interpolate the colors of the specified contour levels from the palette.
  • Fix issue when converting the colors from floating point RGB values to integers; replaced int() with numpy.around() to more accurately represent the integer values (int() simply truncates the decimal places).
  • Create reasonable default contour levels for each data type.
  • Rename variables, arrays, and command line arguments to be more intuitive and make Kalpana more sustainable and extensible.
  • Add explanatory comments.
  • Reduce repeated code in if/else/elif blocks through the use of Python dictionaries to account for the differences between different file types.
  • Correct issues and incomplete implementations associated with repeated code while facilitating the extension to new file types.
  • Reduce line count by 20%.