Exporting images as .png files

Use this procedure to export images as .png files.

  1. In the IRIS Focus Map view, set up the view you want to save.

    For example, you can save the settings for:

    • Weather products
    • Map tools such as the cross-section and tracking tools
    • Zoom level
  2. Select Saved Views > Save.
  3. Name the view and select Save.

    The new view is added to the Saved Views list for your future use.

  4. Configure your web server to access the IRIS Focus image export service:
    @Request: POST <your IRIS Focus URL>/focus-webapp/api/v2/image-export/get-image
    @Produces: "image/png"
  5. Configure the following parameters:
    Parameter Description
    username

    IRIS Focus user name

    For a smooth user experience, Vaisala recommends that you use the dedicated image-export account created at time of installation for exporting images.
    password

    IRIS Focus password for the user

    time

    Time, in ISO-8601 format:

    [YYYY]-[MM]-[DD]T[hh:mm:ss.sssZ]

    Example: 2024-06-18T16:25:23.000Z

    widthPx

    Width of the exported image, in pixels.

    heightPx

    Height of the exported image, in pixels.

    savedViewName

    The name of the saved view you created in 3.

    savedViewUser

    (Optional) Used if you configure a specific user for exporting images (recommended).

  6. Instead of 4 and 5, you can run the export from the command line by creating a script and setting-up a cron job. For example:
    1. Create a Python script for the image export such as the following:
      #!/usr/bin/python
      # -*- coding: utf-8 -*-
      from requests_futures.sessions import FuturesSession
      import datetime
      APP_URL = "your_url_here"
      IMAGE_EXPORT_LOC = "/focus-webapp/api/v2/image-export/get-image"
      FILE_PATH = "yourpath_and_nameofoutputimagesinpng_here"
      USERNAME = "username_here"
      PASSWORD = "password_here"
      TIME = datetime.datetime.utcnow().isoformat()
      WIDTH = "1000"
      HEIGHT = "700"
      VIEW = "view_name_here"
      def main():
          session = FuturesSession()
          req_params = {"username": USERNAME, "password": PASSWORD, "time": TIME, "savedViewName": VIEW, "widthPx": WIDTH, "heightPx": HEIGHT}
          future_one = session.post(APP_URL + IMAGE_EXPORT_LOC, params=req_params, verify=False)    # wait for the request to complete, if it hasn't already
          res = future_one.result()
          print('{0} response status: {1}'.format(TIME, res.status_code))
          if res.status_code == 200:
              with open(FILE_PATH, 'wb') as f:
                  f.write(res.content)
      
      if __name__ == '__main__':
          main()

      Although the example image-export.py script saves only one snapshot, you can edit it to loop a set number of times and get multiple snapshots at a time.

    2. Type crontab -e in the terminal and add, for example, the following line to the crontab file (add your own paths and arguments).
      */15 * * * * /usr/bin/python
              /path/to/script/image-export.py >> /path/to/log/export.log 2>&1

      This executes the image-export.py script every 15 minutes and saves a single snapshot as a PNG file to the server.