Skip to content

Australian 'Search' Extensions

dcapslock edited this page Oct 31, 2020 · 22 revisions

The Weewx Responsive skin has some additional 'search' extensions to allow for display Australia 'Feels Like' description as well as display of BOM forecast information.

Usage

Copy aussearch.py to your weewx user folder. See Custom code and extensions in the weewx users guide.

You will need to include in user.aussearch.ausutils as a search_list_extension in your skin. This is set in the [CheetahGenerator] section. The Responsive skin.conf looks like below. Comment out the line including user.aussearch.ausutils to use aussearch in the Responsive skin.

[CheetahGenerator]
...
 # To use the aussearch extensions in this skin
 # you need to have downloaded Auusearch user extension as per
 # https://github.com/dcapslock/weewx-responsive-skin/wiki/Australian-%27Search%27-Extensions
 # end then uncomment the line below
 # search_list_extensions = user.aussearch.ausutils

Once aussearch.py is part of your weewx installation, your skins will be able to reference the $aus search tag.

##Feels Like

The Feels Like extension allows for translating the apparent temperature into a description. From weewx version 3.5 onwards, the observation appTemp is calculated from temperature, humidity and wind.

Feels Like text is derived from the Australian Bureau of Meteorology (BOM) standard text. See BOM Weather Words and select the Temperature tab. You will see that there are different words use for different climatic areas at different times of the year. The Feels Like extension allows for all by using a localisation via skin.conf. The skin.conf shown below is from the Responsive Skin and has details of how the localisation works. It is best to review this configuration information while having the BOM Weather Words handy.

[[feelslike]]
 # Set feelslike parameters
 #
 # A list of 4 settings - DaySummer, NightSummer, DayWinter, NightWinter.
 #
 # DaySummer one of: DaySummerCoastRanges, DaySummerInlandPlains, DaySummerTropics
 # NightSummer one of: NightSummerSouthRanges, NightSummerNorth, NightSummerTropics
 # DayWinter one of: DayWinterSouthRanges, DayWinterNorth, DayWinterTropics
 # NightWinter one of: NightWinterSouthRanges, NightWinterNorth, NightWinterTropics
 #
 # See http://www.bom.gov.au/info/wwords/, 'Temperature' tab.
 # Default is that for Sydney i.e...
 # feelslikeLocal = DaySummerCoastRanges, NightSummerSouthRanges, DayWinterSouthRanges, NightWinterSouthRanges

 feelslikeLocal = DaySummerCoastRanges, NightSummerSouthRanges, DayWinterSouthRanges, NightWinterSouthRanges

You can get the Feels Like text for an apparent temperature using the appTemp as follows

$aus.feelslike($day.appTemp.max.raw, $day.appTemp.maxtime.raw)

The feelslike search function takes in the apparent temperature, and the time of day for that temperature. The above code is for the Feels Like text for the maximum apparent temperature of the day.

Forecast

The forecast part of the 'search' extensions is a simple wrapper of the BOM forecast XML files. The extension now allows for localisation via skin.conf without any changes to template files.

Localities file

Each state has a localities file. The skin.conf for the Responsive Skin includes localities files for all states as shown below. Uncomment out your state. Note: Any uncommented file will be downloaded twice a day, so manage what files you use accordingly.

[[xml_files]]
 # Localities files
 # Inspect file to find your locality
 # Look for XML Node <area type="location" description="<locality>">
 # or go to http://www.bom.gov.au/<state>/forecasts/map7day.shtml
 NSW = ftp://ftp.bom.gov.au/anon/gen/fwo/IDN11060.xml
 #VIC = ftp://ftp.bom.gov.au/anon/gen/fwo/IDV10753.xml
 #QLD = ftp://ftp.bom.gov.au/anon/gen/fwo/IDQ11295.xml
 #SA =  ftp://ftp.bom.gov.au/anon/gen/fwo/IDS10044.xml
 #WA =  ftp://ftp.bom.gov.au/anon/gen/fwo/IDW14199.xml
 #TAS = ftp://ftp.bom.gov.au/anon/gen/fwo/IDT16710.xml
 #ACT = ftp://ftp.bom.gov.au/anon/gen/fwo/IDN11060.xml
 #NT =  ftp://ftp.bom.gov.au/anon/gen/fwo/IDD10207.xml

You need to specify the localities file to use in the [[local]] section in skin.conf

[[local]]
...
 # Set Forecast Locality file from list in xml_files config node
 # Used for forecast summary on homepage and Full Forecast page
 FC_LOCAL = NSW

You then need to specify your locality. The comments in the configuration above gives a clue to this. You can either inspect the file to look for your locality or go to your state forecast map page to see what localities are available. Once you have found your locality you then set it in the [[localities]] section of skin.conf. (Forecast map links: NSW - VIC - QLD - SA - WA - TAS - ACT - NT)

[[localities]]
 # Set index page locality. One locality which exists in the forecast 
 # file referenced by FC_LOCAL
 # Look for XML Node <area type="location" description="<locality>">
 # Used for forecast summary on homepage and main locality on Full Forecast page
 # or go to http://www.bom.gov.au/<state>/forecasts/map7day.shtml
 index_locality = Parramatta

District file

Each forecast district area has a file. The skin.conf for the Responsive Skin has a number of known files. If yours is not listed use the following procedure to find your district forecast. If yours is listed, review Step 6 below to point template localisations to your file. Uncomment out your district. Note: Any uncommented file will be downloaded twice a day, so manage what files you use accordingly.

  1. Navigate to your state district forecast map overview page (NSW - VIC - QLD - SA - WA - TAS - ACT - NT)

  2. Click on the district you wish to use.

  3. On the district page look for Product at the bottom of the page. Next to product will be a string like identifier such as IDV17101.

  4. Craft your district forecast file using the format show below

    ftp://ftp.bom.gov.au/anon/gen/fwo/<product_id>.xml
    e.g. ftp://ftp.bom.gov.au/anon/gen/fwo/IDV17101.xml
    
  5. Include this in your skin.conf in the [[xml_files]] section.

  6. Specify for your templates to use your district file by setting FC_DISTRICT in [[local]] in skin.conf

    [[xml_files]]
    ...
        # District forecast files (detailed forecasts)
        # Note that same BOM forecast pages seem to have grandfathered arrangements
        # When looking for a Disrtict forecast page it should have a district heading
        # over the detailed forecast text. The ID you want to then try is usually the 
        # second ID listed at the bottom of the page.
        #
        # If you need help send through your location to weather@carlingfordweather.sydney
        #
        # The skin.conf hosted on Github has tested forecast districts.
        # If you find a district not listed and it works OK please send through 
        # to weather@carlingfordweather.sydney
    
        # NSW
        SYDNEY = ftp://ftp.bom.gov.au/anon/gen/fwo/IDN10064.xml
        #CENTRAL_COAST = ftp://ftp.bom.gov.au/anon/gen/fwo/IDN11052.xml
        #HUNTER = ftp://ftp.bom.gov.au/anon/gen/fwo/IDN11026.xml
        #ILLAWARRA = ftp://ftp.bom.gov.au/anon/gen/fwo/IDN11027.xml
    
        # QLD
        #CAPRICORNIA = ftp://ftp.bom.gov.au/anon/gen/fwo/IDQ10170.xml
    
        # SA
        #ADELAIDE = ftp://ftp.bom.gov.au/anon/gen/fwo/IDS10034.xml
        #MOUNT_LOFTY_RANGES = ftp://ftp.bom.gov.au/anon/gen/fwo/IDS11041.xml
    ...
    [[local]]
    ...
       # Set Forecast District file from list in xml_files config node
       # Used for Full Forecast page
       FC_DISTRICT = SYDNEY
    

Warnings

Each state has a Warning file. The warnings files for each state have been included in the Responsive Skin. Uncomment out your state. Note: Any uncommented file will be downloaded twice a day, so manage what files you use accordingly. Set your state warning file in the [[local]] as shown below.

[[xml_files]]
...
 # Warnings Files
 NSW_WARNINGS = http://www.bom.gov.au/fwo/IDZ00054.warnings_nsw.xml
 #VIC_WARNINGS = http://www.bom.gov.au/fwo/IDZ00059.warnings_vic.xml
 #QLD_WARNINGS = http://www.bom.gov.au/fwo/IDZ00056.warnings_qld.xml
 #WA_WARNINGS = http://www.bom.gov.au/fwo/IDZ00060.warnings_wa.xml
 #SA_WARNINGS = http://www.bom.gov.au/fwo/IDZ00057.warnings_sa.xml
 #TAS_WARNINGS = http://www.bom.gov.au/fwo/IDZ00058.warnings_tas.xml
 #ACT_WARNINGS = http://www.bom.gov.au/fwo/IDZ00054.warnings_nsw.xml
 #NT_WARNINGS = http://www.bom.gov.au/fwo/IDZ00055.warnings_nt.xml
...
[[local]]
 # Set warning file from list in xml_files config node
 WARNINGS = NSW_WARNINGS

Forecast usage

The Responsive Skin includes summary forecast information on the home page and a full forecast page. On the home page is locality forecast with précis information. This information comes from the Localities file described above. The full forecast page includes forecast information for the locality and area, with information coming from both the Localities file and District files described above.

If you would like to craft your own template files, the few examples below will point you in the right direction.

XML File

<?xml version="1.0" encoding="UTF-8"?>
 <amoc>
 ...
 <issue-time-local tz="EDT">2016-10-08T09:45:50+11:00</issue-time-local>
...
</amoc>

Template Usage

 #set $FC = $aus.FC_LOCAL.forecast('area',description=str($aus.index_locality))
 <h6><small>
 #set $issueDateTime = $aus.FC_LOCAL.amoc.issue__time__local.string
 Forecast for $aus.index_locality<br/>
 Issued at $dateutil.parser.parse($issueDateTime).strftime("%I:%M%p") $aus.FC_LOCAL.amoc.issue__time__local.tz on $dateutil.parser.parse($issueDateTime).strftime("%a %-d %b %Y")
 </small></h6>

XML File

<?xml version="1.0" encoding="UTF-8"?>
 <forecast>
     <area type="location" description="Parramatta" aac="NSW_PT111" parent-aac="NSW_PW005">
         <forecast-period end-time-utc="2016-10-08T13:00:00Z" start-time-utc="2016-10-07T22:30:40Z" end-time-local="2016-10-09T00:00:00+11:00" start-time-local="2016-10-08T09:30:40+11:00" index="0">
             <element type="forecast_icon_code">17</element>
             <element type="air_temperature_maximum" units="Celsius">22</element>
             <text type="precis">Possible shower developing.</text>
             <text type="probability_of_precipitation">30%</text>
         </forecast-period>

Template Usage

...
#set $FC = $aus.FC_LOCAL.forecast('area',description=str($aus.index_locality))
...
$FC.getNode('forecast-period',index=0).getNode('element',type="air_temperature_maximum")
...

The following is to be noted on the XML wrapper code

  • If the child item is individual then you should be able to access directly using the usual dot code format. The first example above shows this.
  • If the child item is one of multiple, then you will need to use getNode with the item name and a search. The second example above shows this.
  • If using dot code format, and the XML node/item has a dash '-' in the name, you will need to access via a double underscore '__'.

The following is to be noted on the search extension code in relation to downloading the XML files

  • A default cache location of /var/lib/weewx/aussearch is used. You can adjust that in your skin.conf file.
  • The XML value of next-routine-issue-time-local under amoc is used to kick off downloading the next update of the forecast file after a staleness time to allow for a delay in the file being generated.
  • For XML files, if a .amoc.xml version exists, it is used to check for an updated XML file. The .amoc.xml version is a small file with date/time of the latest version of the XML file. This mechanism will catch forecast updates outside of the regular twice daily issues of forecasts.

For more examples look at the forecast code included in the Responsive skin.

Forecast Icons

If you use the BOM Forecast and run your site secure https, you will notice that latest versions of Chrome will not display the forecast icons. This is because Chrome will not allow any non secure assets to be display in a secure site.

To allow for custom icons to be displayed, make sure you have the latest aussearch.py (31/10/2020) and add sections below to your skin.conf. You need to specify the folder where icons files are stored on your website and the files you wish to use.

There are no default file sets. You will need to create your own or source from Shutterstock. Envato Elements etc. Recommended large icon size is 48 x 48. Recommended small icon size is 24 x 24.

[[aussearch]]
 ...
 
 # icons folder where any specific weather icons will be served on website
 icons_folder = icons
 
 [[icons]]
     # Set Weather Forecast Icons
     #
     # 1 : Sunny, 2 : Clear, 3 : Partly Cloudy, 4 : Cloudy, 5 : na, 6 : Haze, 7 : na
     # 8 : Light Rain, 9 : Wind, 10 : Fog, 11 : Showers, 12 : Rain, 13 : Dust, 14: Frost
     # 15 : Snow, 16: Storm, 17 : Light Showers, 18 : Heavy Showers

     1 = <Sunny File>      
     2 = <Clear File>
     3 = <Partly Cloudy File>
     4 = <Cloudy File>
     5 = ''
     6 = <Haze File>
     7 = ''
     8 = <Light Rain File>
     9 = <Wind File>
     10 = <Fog File>
     11 = <Showers File>
     12 = <Rain File>
     13 = <Dust File>
     14 = <Frost File>
     15 = <Snow File>
     16 = <Storm File>
     17 = <Light Showers File>
     18 = <Heavy Showers File>

 [[iconsSml]]
     # Set Weather Forecast Icons
     #
     # 1 : Sunny, 2 : Clear, 3 : Partly Cloudy, 4 : Cloudy, 5 : na, 6 : Haze, 7 : na
     # 8 : Light Rain, 9 : Wind, 10 : Fog, 11 : Showers, 12 : Rain, 13 : Dust, 14: Frost
     # 15 : Snow, 16: Storm, 17 : Light Showers, 18 : Heavy Showers

     1 = <Sunny File>      
     2 = <Clear File>
     3 = <Partly Cloudy File>
     4 = <Cloudy File>
     5 = ''
     6 = <Haze File>
     7 = ''
     8 = <Light Rain File>
     9 = <Wind File>
     10 = <Fog File>
     11 = <Showers File>
     12 = <Rain File>
     13 = <Dust File>
     14 = <Frost File>
     15 = <Snow File>
     16 = <Storm File>
     17 = <Light Showers File>
     18 = <Heavy Showers File>

 [[rainImgs]]
     # Set Rain Image Icons
     #
     # 0: 0 percent, 5 : 5 percent, 10: 10 percent, 20 : 20 percent, 30 : 30 percent, 40 : 40 percent, 50 : 50 percent
     # 60 : 60 percent, 70: 70 percent, 80 : 80 percent, 90 : 90 percent, 95 : 95 percent, 100 : 100 percent  

     0 = <0% Rain Image File>
     5 = <5% Rain Image File>
     10 = <10% Rain Image File>
     20 = <20% Rain Image File>
     30 = <30% Rain Image File>
     40 = <40% Rain Image File>
     50 = <50% Rain Image File>
     60 = <60% Rain Image File>
     70 = <70% Rain Image File>
     80 = <80% Rain Image File>
     90 = <90% Rain Image File>
     95 = <95% Rain Image File>
     100 = <100% Rain Image File>