i am trying to calculate heating/cooling degree day using (Tbase - Ta) formula Tbase is usually 65F and Ta = (high_temp + low_temp)/2
(e.x)
high_temp = 96.5F low_temp=65.21F then
mean=(high_temp + low_temp)/2
result = mean - 65
65 is average room temperature
if result is > 65 then cooling degree day(cdd) else heating degree day(hdd)
i get weather data from two api
weatherbit
darksky
in weatherbit the provide both cdd and hdd data, but in darksky we need to calculate using above formula (Tbase - Ta)
my problem is both api show different result (e.x)
darksky json response for day
{
"latitude": 47.552758,
"longitude": -122.150589,
"timezone": "America/Los_Angeles",
"daily": {
"data": [
{
"time": 1560927600,
"summary": "Light rain in the morning and overnight.",
"icon": "rain",
"sunriseTime": 1560946325,
"sunsetTime": 1561003835,
"moonPhase": 0.59,
"precipIntensity": 0.0057,
"precipIntensityMax": 0.0506,
"precipIntensityMaxTime": 1561010400,
"precipProbability": 0.62,
"precipType": "rain",
"temperatureHigh": 62.44,
"temperatureHighTime": 1560981600,
"temperatureLow": 48,
"temperatureLowTime": 1561028400,
"apparentTemperatureHigh": 62.44,
"apparentTemperatureHighTime": 1560981600,
"apparentTemperatureLow": 46.48,
"apparentTemperatureLowTime": 1561028400,
"dewPoint": 46.61,
"humidity": 0.75,
"pressure": 1021.81,
"windSpeed": 5.05,
"windGust": 8.36,
"windGustTime": 1560988800,
"windBearing": 149,
"cloudCover": 0.95,
"uvIndex": 4,
"uvIndexTime": 1560978000,
"visibility": 4.147,
"ozone": 380.8,
"temperatureMin": 49.42,
"temperatureMinTime": 1561010400,
"temperatureMax": 62.44,
"temperatureMaxTime": 1560981600,
"apparentTemperatureMin": 47.5,
"apparentTemperatureMinTime": 1561014000,
"apparentTemperatureMax": 62.44,
"apparentTemperatureMaxTime": 1560981600
}
]
},
"offset": -7
}
python calculation
response = result.get("daily").get("data")[0]
low_temp = response.get("temperatureMin")
hi_temp = response.get("temperatureMax")
mean = (hi_temp + low_temp)/2
#65 is normal room temp
print(65-mean)
here mean is 6.509999999999998
65 - mean = 58.49
hdd is 58.49 so cdd is 0
same date in weatherbit json response is :
{
"threshold_units": "F",
"timezone": "America/Los_Angeles",
"threshold_value": 65,
"state_code": "WA",
"country_code": "US",
"city_name": "Newcastle",
"data": [
{
"rh": 68,
"wind_spd": 5.6,
"timestamp_utc": null,
"t_ghi": 8568.9,
"max_wind_spd": 11.4,
"cdd": 0.4,
"dewpt": 46.9,
"snow": 0,
"hdd": 6.7,
"timestamp_local": null,
"precip": 0.154,
"t_dni": 11290.6,
"temp_wetbulb": 53.1,
"t_dhi": 1413.9,
"date": "2019-06-20",
"temp": 58.6,
"sun_hours": 7.6,
"clouds": 58,
"wind_dir": 186
}
],
"end_date": "2019-06-21",
"station_id": "727934-94248",
"count": 1,
"start_date": "2019-06-20",
"city_id": 5804676
}
here hdd is 6.7 and cdd is 0.4
can you explain how they get this result ?
You need to use hourly data to calculate the HDD and CDD, and then average them to get the daily value.
More details here: https://www.weatherbit.io/blog/post/heating-and-cooling-degree-days-weather-api-release
Related
I am having an issue with FormRecognizer not behaving how I have seen it should. Here is the dilemma
I have an Invoice that, when run through https://{endpoint}/formrecognizer/v2.0/layout/analyze
it recognized the table in the Invoice and generates the proper JSON with the "tables" node. Here is an example of part of it
{
"rows": 8,
"columns": 8,
"cells": [
{
"rowIndex": 0,
"columnIndex": 4,
"columnSpan": 3,
"text": "% 123 F STREET Deer Park TX 71536",
"boundingBox": [
3.11,
2.0733
],
"elements": [
"#/readResults/0/lines/20/words/0",
"#/readResults/0/lines/20/words/1"
]
}
When I train a model with NO labels file https://{endpoint}/formrecognizer/v2.0/custom/models It does not generate an empty "tables" node, but it generates (tokens). Here is an example of the one above without "table"
{
"key": {
"text": "__Tokens__12",
"boundingBox": null,
"elements": null
},
"value": {
"text": "123 F STREET",
"boundingBox": [
5.3778,
2.0625,
6.8056,
2.0625,
6.8056,
2.2014,
5.3778,
2.2014
],
"elements": null
},
"confidence": 1.0
}
I am not sure exactly where this is not behaving how intended, but any insight would be appreciated!
If you train a model WITH labeling files, then call FR Analyze(), the FR service will call the Layout service, which returns tables in "pageResults" section.
I have a weird issue, where doing an out-operation on a few edges causes my RU cost to triple. Hope someone can help me shed light on why + what I can do to mitigate it.
I have a Graph in CosmosDB, where there are two types of vertex labels: "Profile" and "Score". Each profile has 0 or 1 score-vertices via a "ProfileHasAggregatedScore" edge. The partitionKey is the ID of the Profile.
If I make the following queries, the RU currently is:
g.V().hasLabel('Profile').out('ProfileHasAggregatedScore')
>78 RU (8 scores found)
And for reference, the cost of getting all vertices of a type is:
g.V().hasLabel('Profile')
>28 RU (110 profiles found)
g.E().hasLabel('ProfileHasAggregatedScore')
>11 RU (8 edges found)
g.V().hasLabel('AggregatedRating')
>11 RU (8 scores found)
And the cost of a single of the vertices or edges are:
g.V('aProfileId').hasLabel('Profile')
>4 RU (1 found)
g.E('anEdgeId')
> 7RU
G.V('aRatingId')
> 3.5 RU
Can someone please help me as to why, making a traversal with only a few vertices along the way (see traversal at the bottom), is more expensive than searching for everything? And is there something I can do to prevent it? Adding a has-filter with the partitionKey does not seem to help. It seems odd that traversing/finding 16 elements more (8 edges and 8 vertices) after finding 110 vertices triples the cost of the operation?
(NB. With 1000 profiles the cost of doing 1 traversal along an edge to the score node is 2200 RU. This seems high, considering the emphasis their Azure team put on it being scalable?)
Traversal if it can help (It seems most of the time is spent finding the edges with the out() step):
[
{
"gremlin": "g.V().hasLabel('Profile').out('ProfileHasAggregatedScore').executionProfile()",
"totalTime": 46,
"metrics": [
{
"name": "GetVertices",
"time": 13,
"annotations": {
"percentTime": 28.26
},
"counts": {
"resultCount": 110
},
"storeOps": [
{
"fanoutFactor": 1,
"count": 110,
"size": 124649,
"time": 2.47
}
]
},
{
"name": "GetEdges",
"time": 26,
"annotations": {
"percentTime": 56.52
},
"counts": {
"resultCount": 8
},
"storeOps": [
{
"fanoutFactor": 1,
"count": 8,
"size": 5200,
"time": 6.22
},
{
"fanoutFactor": 1,
"count": 0,
"size": 49,
"time": 0.88
}
]
},
{
"name": "GetNeighborVertices",
"time": 7,
"annotations": {
"percentTime": 15.22
},
"counts": {
"resultCount": 8
},
"storeOps": [
{
"fanoutFactor": 1,
"count": 8,
"size": 6303,
"time": 1.18
}
]
},
{
"name": "ProjectOperator",
"time": 0,
"annotations": {
"percentTime": 0
},
"counts": {
"resultCount": 8
}
}
]
}
]
enter code here
I am trying to create nodes whose radius depend on the amount value in the link array. The data structure is as shown below:
{ "nodes": [{"id": "site01", "x": 317.5, "y": 282.5},
{"id": "site02", "x": 112, "y": 47},
{"id": "site03", "x": 69.5,"y": 287},
{"id": "site04", "x": 424.5, "y": 99.5},
],
"links": [
{"node01": "site01", "node02": "site04", "amount": 10},
{"node01": "site03", "node02": "site02", "amount": 120},
{"node01": "site01", "node02": "site03", "amount": 50},
{"node01": "site04", "node02": "site02", "amount": 80}]
}
The radius must be proportional to the total amount. For example, site01 must be of radius 60 while site02, 200. I've tried few codes but it doesn't seem to work.
var nodeRadius = {};
data.links.forEach(function (n){
nodeRadius[n.id] = n;
});
nodes.attr("r", function (d) {return nodeRadius[d.node01].amount;})
Please suggest a working code.
DATA to be search through:
{
"epicUserHandle": "HaaZeeY",
"stats": {
"p2": {
"trnRating": {
"label": "TRN Rating",
"field": "TRNRating",
"category": "Rating",
"valueInt": 1193,
"value": "1193",
"rank": 3210238,
"percentile": 56.0,
"displayValue": "1,193"
},
"top1": {
"label": "Wins",
"field": "Top1",
"category": "Tops",
"valueInt": 46,
"value": "46",
"rank": 15163718,
"percentile": 0.8,
"displayValue": "46"
},
My code:
url = "https://api.fortnitetracker.com/v1/profile/{}/{}".format(platform,
username)
headers = {'TRN-Api-Key' : 'MY API KEY'}
r = requests.get(url, headers=headers)
#p2 = Solo
#p10 = Duo
#p9 = Squad
tempory_dict = {}
result = r.json()['stats']['p2']['top1']
for r in result:
#WHAT DO I PUT HERE
tempory_dict['Wins'] = #VALUE
print(tempory_dict['Wins'])
What do I need to do here? I want it to find the "value" and save that in the tempory_dict['Wins']. I'm new to requests and not sure how to iterate through it all to find value.
Thanks.
You are almost there actually, having:
result = r.json()['stats']['p2']['top1'], you actually assign
{
"label": "Wins",
"field": "Top1",
"category": "Tops",
"valueInt": 46,
"value": "46",
"rank": 15163718,
"percentile": 0.8,
"displayValue": "46"
}
to result variable, so all you need to do is just go one step further and assign:
tempory_dict['Wins'] = result['value']
Is there a faster way to create view on CouchDB?
My data is something like this:
{"docs":[{
"c_custkey": 1,
"c_name": "Customer#000000001",
"c_address": "IVhzIApeRb",
"c_city": "MOROCCO 0",
"c_nation": "MOROCCO",
"c_region": "AFRICA",
"lineorder": [{
"lo_orderkey": 164711,
"lo_linenumber": 1,
"lo_custkey": 1,
"lo_partkey": 82527,
"lo_suppkey": 1848,
"lo_quantity": 34,
"lo_extendedprice": 5132368,
"lo_revenue": 2816872,
"orderdate": [{
"d_datekey": 19920426,
"d_date": "April 26, 1992",
"d_dayofweek": "Monday",
"d_month": "April",
"d_year": 1992,
"d_yearmonthnum": 199204,
}],
"part": [{
"p_partkey": 82527,
"p_name": "steel tomato",
"p_mfgr": "MFGR#4",
"p_category": "MFGR#45",
"p_brand1": "MFGR#452",
}],
"supplier": [{
"s_city": "MOZAMBIQU8",
"s_nation": "MOZAMBIQUE",
"s_region": "AFRICA",
}]
}, {
"lo_orderkey": 164711,
"lo_linenumber": 2,
"lo_custkey": 1,
"lo_partkey": 26184,
"lo_suppkey": 1046,
"lo_orderdate": 19920426,
"lo_quantity": 15,
"lo_extendedprice": 1665270,
"orderdate": [{
"d_datekey": 19920426,
"d_date": "April 26, 1992",
"d_dayofweek": "Monday",
"d_month": "April",
"d_year": 1992,
"d_yearmonthnum": 199204,
}],
"part": [{
"p_partkey": 26184,
"p_name": "chartreuse green",
"p_mfgr": "MFGR#2",
"p_category": "MFGR#23",
"p_brand1": "MFGR#2329",
}],
"supplier": [{
"s_suppkey": 1046,
"s_city": "SAUDI ARA2",
"s_nation": "SAUDI ARABIA",
"s_region": "MIDDLE EAST",
}]
},...
And I'm creating the view this way using FUTON, but it takes 30 min:
Map function:
function(doc)
{
var c_city=doc.c_city
var c_nation=doc.c_nation
if (c_nation=="UNITED STATES"){
for each (lineorder in doc.lineorder) {
for each (supplier in lineorder.supplier){
var s_city=supplier.s_city
var s_nation=supplier.s_nation
}
if (s_nation=="UNITED STATES"){
for each (orderdate in lineorder.orderdate) {
var d_year=orderdate.d_year
}
if (d_year>=1992 && d_year<=1997){
emit({d_year:d_year,c_city:c_city,s_city:s_city},lineorder.lo_revenue);
}
}
}
}
}
Reduce Function: "_sum"
My database have 2 GB of this kind of data.
This is obviously not your real view (lineorder vs. lineorders and there's no lo_revenue), so I won't waste time finessing it. Instead let me say that for a 2GB data set with who knows how many lineorders iterations per document, 30 minutes is not at all surprising.