How to use BOM Api for weather, tide and swell - weather

I have lot of search on the BOM api of Australia. There is no easy way to get the weather details like wind, temp, humidity etc. They provide data in by ftp in .xml format. There is no json format at all. Some where they provide the data in json format.Below is link of the json response.
http://www.bom.gov.au/fwo/IDW60801/IDW60801.94802.json
but the biggest problem with the product id, there is IDW60801 product ID of west Australia for the "observations" data. It is has the following information :- weather, swell, pressure and wind. but it has the previous day details not forecast details.
There is wmo id :- 94802
I got some wmo id from somewhere but it not for all the location of the Australia. I want to access weather forecast of all the location of the Australia in json or . xml format.
If anybody know how we get all the details please let me know.
Here is the ftp link for the products :-
ftp://ftp.bom.gov.au/anon/sample/catalogue/
ftp://ftp.bom.gov.au/anon/sample/catalogue/Observations/
ftp://ftp.bom.gov.au/anon/sample/catalogue/Forecasts/
ftp://ftp.bom.gov.au/anon/sample/catalogue/Tide/
I also got the AAC identifier list of the Australia's cities by the BOM.If getting the details by AAC identifier please let me know the url for that so i can retrive the details by it.
Thanks

You expressed your problem as:
I have lot of search on the BOM api of Australia. There is no easy way
to get the weather details like wind, temp, humidity etc. They provide
data in by ftp in .xml format. There is no json format at all.
If I understand your need, is to pull weather data from BOM in JSON format?
So the first thing is to identify an IDV near you. In this case I'm using, for Melbourne, it's IDV60901.
So here's the JSON request: http://www.bom.gov.au/fwo/IDV60901/IDV60901.95936.json
You can find these under "Observations - individual stations" on http://www.bom.gov.au/catalogue/data-feeds.shtml
The response includes a header and then the following data on a half-hourly basis (where "sort order" is the most recent observation). Note that because this location is not on the coast it doesn't provide ocean/bay conditions. However if you select an IDV where that data is relevant, then you will find observations for ocean conditions:
{
"sort_order": 0,
"wmo": 95936,
"name": "Melbourne (Olympic Park)",
"history_product": "IDV60901",
"local_date_time": "12/12:30pm",
"local_date_time_full": "20171012123000",
"aifstime_utc": "20171012013000",
"lat": -37.8,
"lon": 145.0,
"apparent_t": 12.4,
"cloud": "-",
"cloud_base_m": null,
"cloud_oktas": null,
"cloud_type_id": null,
"cloud_type": "-",
"delta_t": 5.9,
"gust_kmh": 28,
"gust_kt": 15,
"air_temp": 16.6,
"dewpt": 4.0,
"press": 1014.7,
"press_qnh": 1014.7,
"press_msl": 1014.7,
"press_tend": "-",
"rain_trace": "0.0",
"rel_hum": 43,
"sea_state": "-",
"swell_dir_worded": "-",
"swell_height": null,
"swell_period": null,
"vis_km": "-",
"weather": "-",
"wind_dir": "WNW",
"wind_spd_kmh": 15,
"wind_spd_kt": 8
}

It wasn't immediately clear to me how to do this, here's what I found:
You can use this endpoint: http://www.bom.gov.au/fwo/<PARAMS...> to retrieve last ~72 hours of weather observations for a particular site.
I got a full list of available weather stations (ID's + labels + coordinates) here:
ftp://ftp.bom.gov.au/anon2/home/ncc/metadata/sitelists/stations.zip
http://www.bom.gov.au/climate/cdo/about/site-num.shtml
the request format is: http://www.bom.gov.au/fwo/ID<STATE>60701/ID<STATE>60701/<STATION_ID>.json
an example query for Cape Bruny in Tasmania: http://www.bom.gov.au/fwo/IDT60701/IDT60701.95967.json
the 95967 in my above example is the station ID
the IDT60701 part is for the state of Tasmania, so for other states:
QLD: IDQ60701
NSW: IDN60701
VIC: IDV60701
NT: IDD60701 (slightly inconsistent convention on this one..)
etc.
There's also a bunch of product codes here: http://www.bom.gov.au/catalogue/anon-ftp.shtml which might be useful somehow..

The AAC codes can be linked with the précis forecast given in the XML files, they also specify the AAC code if you want a forecast for a location.
I've been working on an R package with a couple other people, bomrang, that does this and a couple other things, it's still under development right now but it is installable from GitHub if you use R.
The current weather is served in json files and can be retrieved and returned in a data frame.
The forecast can be retrieved and linked to location names via AAC codes and returned as a data frame.
https://github.com/ToowoombaTrio/bomrang

Related

API Response - How to handle response in React

I'm trying to work with an API that sends out a list of questions to create a question set. This is the response from the API:
{"questionSetItems":[[1,"From which date would you like your insurance to start from?","This is the date on which you want the policy to begin. The policy will not pay for any claims which occur prior to this date.","Dropdown",[],"",false],[2,"What is your title?","","DropDown",[],"",false],[3,"What is your title?","","DropDown",[],"",false],[4,"What is your forename?","","Edit",[],"",false],[5,"What is your surname?","","Edit",[],"",false],[6,"What is your date of birth?","","Date",[],"",false],[7,"You and your spouse or partner are not: <br\/>Professional Sportspeople<br\/>Professional Entertainers<br\/>Professional Gamblers<br\/>Moneylenders or Pawnbrokers<br\/>Bailiffs or Bodyguards<br\/>Bar Managers<br\/>Car Dealers\/Salespeople<br\/>Circus or Fairground Employees\/Owners<br\/>Clairvoyants, Tarot Readers or Palmistry Experts<br\/>Croupiers, Gaming Club Managers\/Proprietors<br\/>Diamond or Metal Dealers<br\/>Exotic Dancers<br\/>Jewellers or Jewellery Consultants<br\/>Street\/Market Traders<br\/>Tattooists<br\/>Student<br\/>Unemployed\/In voluntary employment<br\/><br\/>Please confirm that you agree to the above statements.","","YesNo",["inputEmploymentYes","inputEmploymentNo"],"",true],[8,"Please select the relevant employment types for both you and your spouse or partner","","ButtonList",["inputSportspeople","inputEntertainers","inputGamblers","inputBar","inputBailiffs","inputMoneyLender","inputTarot","inputCircus","inputCar","inputExotic","inputDiamond","inputCroupiers","inputTattooists","inputStreet","inputJewellers","inputVoluntary","inputUnemployed","inputOther","inputStudent"],"partnerType",false],[9,"Do you need to add a joint policyholder?","","YesNo",["inputJointHolderYes","inputJointHolderNo"],"",true]],"headerLogo":"","cOB":"STDH","isLastPage":false}
How to look through the array in React?
yo
u can use like this .u can keep it in a variable name and u can check in which key ur getting the array of datas , then you can map the fields and u will get data
enter image description here

Upload Alexa Slot Types via API

Is there anyway of uploading Custom Slot Types values via an API, so that you do not need to type them in manually using the new Alexa Skill Builder interface (if you have many of them):
I haven't found anything.
My recommendation is to get the model via SMAPI first, edit the json file with your new values and update it via SMAPI again.
ask api get-model -s "enter your skill id here" --stage development -l en-US > model.json
in the model.json file you can see the slots definition. Change it (with a script or manually) and update the model again
Reference to both commands:
https://developer.amazon.com/docs/smapi/ask-cli-command-reference.html#update-model-subcommand
https://developer.amazon.com/docs/smapi/ask-cli-command-reference.html#update-model-subcommand
It seems not (after searching). There is a feature request logged here with Amazon:
https://forums.developer.amazon.com/questions/9640/api-to-upload-intent-schema-and-sample-utterances.html#answer-77902
Yes you can do this via the SMAPI API/CLI. Take a look at https://developer.amazon.com/docs/smapi/ask-cli-intro.html for a full detail - it allows for full model editing via JSON.
In the left bar bellow the "Intents" and "Slot" is the option "JSON Editor". There you can write a JSON for the new intents you want to add.
Example without slot type
{
"name":"YesIntent",
"samples":[
"Yes",
"Yeah",
"I do",
"I am"
]
}
Example with slot type
{
"name":"NumberIntent",
"slots":[
{
"name":"number",
"type":"AMAZON.NUMBER"
}
],
"samples":[
"{number} is my number",
"{number}",
"my number is {number}"
]
}
As other answers suggest, you can use the SMAPI.
Alternatively, you can select the "code editor" tab on the left and drag/drop or copy/paste your schema json code.
https://github.com/williamwdu/Alexa-Custom-Slot-Generator
I wrote this to convert csv/excel to JSON format so you can paste it into code editor.
Let me know if you have any question.
There is no README for the code coz I have no time these days

Missing States in creating county map visuals using Python3 Vincent Vega

I am using Vincent to plot county level map for US. Took example data for 2016 elctions. It however doesnt plot for some states like California. I have checked data and FIPS codes seems to exist but still showing blank there. Any ideas what may be going on? I got county data from topo.json.
geo_data_c2 = [{'name': 'counties',
'url': county_topo,
'feature': 'us_counties.geo'}]
vis_election_counties = vincent.Map(data=merged, geo_data=geo_data_c2, scale=1000,
projection='albersUsa', data_bind='per_dem',
data_key='combined_fips', map_key={'counties': 'properties.FIPS'})
#Change our domain for an even inteager
vis_election_counties.scales['color'].domain = [0,1]
vis_election_counties.legend[![enter image description here][1]][1](title='per_dem')
vis_election_counties.to_json('vega.json')
vis_election_counties.display()
The FIPS codes for counties in the first ~7 states alphabetically need to be zero-padded to 5 characters.
Arapahoe County, CO has FIPS code 8005, which is represented as "08005" in https://raw.githubusercontent.com/jgoodall/us-maps/master/topojson/county.topo.json
merged['combined_fips'] = merged['combined_fips'].map(lambda i: str(i).zfill(5))

in Watson Discovery News Feed API, limiting articles returned by date

Per the API documentation, manipulating the vales of "start" and "end" will result in different data sets being returned. Strangely, changing the values of start and end resulted in the same result being returned. What am I missing? Thanks!
qopts = {'query': '/automotive and vehicles',
'aggregation' : '[term(yyymmdd).term(docSentiment.type,count:3)]',
'return': 'docSentiment.type,yyyymmdd',
'count': '50',
'start': 'now-2w',
'end' : 'now-1w',
'offset': my_offset}
my_query = discovery.query(my_disc_environment_id, my_disc_collection_id, qopts)
I hope it is helpful for you.
I am not sure if this is right answer for you because I have limited information.
First of all, please check the number of return-sets. if the return-set has more then 50 dataset, result could be same. (might count param. -1 = unlimited in the rest API of WCA (Watson Context Analytics)
Second, if you can check the log from the server side, you can see the full query which manipulated from WATSON engine.
Last, I am not really sure that watson REST-API can recognize 'now-2w' style start-end form. Would you please link the tutorial? In my previous project, I wrote the start-end date by Y-M-D form.
Good Luck

how to get array from and xml file in swift

I am new to swift but I have made an android app where a string array is selected from an xml file. This is a large xml file that contains a lot of string arrays and the app gets the relevant string array based on a user selection.
I am now trying to develop the same app for iOS using swift. I would like to use the same xml file but I can not see and easy way to get the correct array. For example, part of the xml looks like this
<string-array name="OCR_Businessstudies_A_Topics">
<item>1. Business objectives and strategic decisions</item>
<item>2. External influences facing businesses</item>
<item>3. Marketing and marketing strategies</item>
<item>4. Operational strategy</item>
<item>5. Human resources</item>
<item>6. Accounting and financial considerations</item>
<item>7. The global environment of business</item>
</string-array>
<string-array name="OCR_Businessstudies_AS_Topics">
<item>1. Business objectives and strategic decisions</item>
<item>2. External influences facing businesses</item>
<item>3. Marketing and marketing strategies</item>
<item>4. Operational strategy</item>
<item>5. Human resources</item>
<item>6. Accounting and financial considerations</item>
</string-array>
If I have the string "OCR_Businessstudies_A_Topics" how do i get the "OCR_Businessstudies_A_Topics" array from the xml file.
This is very straight forward in android and although I have used online tutorials for swift it seems like I have to parse the xml file but do not seem to be getting anywhere.
Is there a better approach than trying to parse the whole xml fie?
Thanks
Barry
You can write your own XML parser, conforming to NSXMLParser or use a library like HTMLReader:
let fileURL = NSBundle.mainBundle().URLForResource("data", withExtension: "xml")!
let xmlData = NSData(contentsOfURL: fileURL)!
let topic = "OCR_Businessstudies_A_Topics"
let document = HTMLDocument(data: xmlData, contentTypeHeader: "text/xml")
for item in document.nodesMatchingSelector("string-array[name='\(topic)'] item") {
print(item.textContent)
}

Resources