Importing NREL Solar Models in to EmonCMS

The node-red calculation is really cool conceptually, and we’ve been playing with it all afternoon, but we’re not sure how to use this since it’s putting out a single point at a time. We want to be able to look at any day for the next year and see what our irradiation curve is going to be. It is also our goal to eventually be able to derate the ideal production curve based on weather as @peter mentioned.

The spreadsheet we get from PVWatts is pretty much perfect for what we’re doing. Ideally we would populate a single feed in advance with values for an entire year and then use that feed to subtract weather from it.


We have data! We got the node-red sun calc working after a little bit of trouble shooting. We don’t know how well it’s tuned in yet, because it’s a cloudy day, so we’re getting some edge-of-cloud effect that is pushing our measurements above what should be the baseline value, followed by the actual clouds (well below baseline). We need a good clear day to tune in the model to match our system exactly. However, in the current implementation, it simply outputs what should be happening now. We still need to be able to write values into the database that represent future timestamps. Is that possible, and if so, how?

Here you can see our system balance graph. Battery charge/discharge is in green/red. Yellow is charge controller output. Blue is total load on the system (shown as negative, below zero). Grey is our super awesome PhotoTX laboratory grade irradiance sensor. And then BROWN is the newest, node-red output of predicted solar power. Except it’s not really predicting, it’s realtime.

Another video about edge of cloud effect here.

1 Like

Updated graph with several additional hours. Turned off the yellow charge controller feed in the multigraph to better show the relationship between the NREL model and the measured irradiance. It’s also a good lesson in system sizing and design, as you can clearly see the phenomenon of the edge-of-cloud effect and why it’s important to give a 1.2x safety factor when choosing a charge controller relative to your array size. Make sure it’s capable of at least 1.2x the nameplate specs of the array! (I’ve got an FM80 with plenty of room to grow)

1 Like

Nice to see you are getting somewhere.

My set-up uses a subflow to calculate the three aspects and add them up - the odd thing is I get a negative value at the start of the day and I have not yet had time to work out why.

The cloud cover is from which is a “free” feed of data and there is another node-red module to pull in the data on demand when you have set-up your API key on their site. Limited queries per day are free but there are enough for once every 5 minutes. The nice thing for me is that they give multiple granularity forecasts including per-hour for the next 24-28 hours - which includes a 0.0 - 1.0 cloud cover estimate. So I just pull out the number per-sample for current, +3 hours and +6 hours.

Here’s my forecast flow (with subflow) if it’s any help.

forecast.txt (6.5 KB)

(You have to add auth info to the function as mentioned)

Here’s a quick graph for a few days ago - the 3 and 6 hours predictions are obviously offset and I can’t see a way in the basic graphing of moving them for visualisation :slight_smile:

1 Like

I think the trick would be to use the bulk upload api and add the forecast period to the timestamp before posting so you are timestamping the “+3hr” and “+6hr” feeds with the prediction 3 or 6 hrs in advance rather than timstamping the prediction for then with the time now.

eg [[unixtime,nodeid,clouds_current][unixtime+10800,nodeid,null,clouds_current][unixtime+21600,null,null,nodeid,clouds_current]]

note the additional “null” strings in the second and third frames, the first frame will post only to the first input of the node, the second frame will not update the first input only the second and the third will update input 3 not the first 2.

This effectively gives one set of 3 values (now,+3hr,+6hr) but each has it’s own timestamp not a common one.

The time the prediction was logged is not useful but is obviously easy to determine from the feed name and the calculated timestamp.

do you have an example spreadsheet?

The bulk upload api is the way to go to upload a large amount of data with predefined timestamps

It should be quite easy to save/export to a csv file from excel in the right format to allow a very simple script to post to emonhub (original) to “pace” the uploads eg 250 frames every 10 secs. Or you write something that does the buffering/throttling/retries and confirmation of delivery etc yourself.

If posting to a phpfina fixed interval feed you will only be able to post upto 48hrs in advance due to restrictions like this line in emoncms, as far as I know the same restriction doesn’t exist in phptimeseries.

If you look at the format of the feed file it may be easier to write a fixed file external to emoncms and transplant it into place if you do not need to be able to update it often. Like a reference feed rather than a recording feed…

1 Like

@pb66, here is the hourly PV performance model for our system by PVWatts:

The idea of writing a fixed external file is a good one, but how do we do that without hosing our entire system? We are not database admins. :confused:

1 Like

The data includes per-hour for the next 48 hours but as always with forecasts the accuracy goers down the further in the future you look, so while it should be feasible to pull per-hour cloud cover numbers for the “next day” from the forecast I am not sure how good this will be. On the other hand, it’s not that hard to do - so I’ll look at this and your next suggestion about using the bulk upload tool.

If the data source is the National Weather Service, it’s updated every three hours. As an NWS Electronics Tech from 2007 to 2012, I saw that process first hand.

Forecasting is as much of an art as it is a science. At the forecast office I worked at, they either nailed it, or they were off by quite a bit. Despite the complexity of the task, they managed to get it right more than 80% of the time. Temp, precip, wind speed/direction, sky conditions, etc. were either dead on, or very close to their predicted values.

One of the things that helps them is the fact all of the senior forecasters, and most of the general forecasters have been at that office for 10 years or more. They know the “lay of the land” so to speak, and are very aware of the idiosyncrasies that drive the local weather.

When you say you are not DB admins do you mean you do not have root access (eg or do you mean you do not have DB admin level skills?

I assumed you were self hosting and had root access, is that right?

Apologies, I haven’t looked at your spreadsheet yet (worked late last night) I have just downloaded it but I’m just heading out again now I will try and take a peek later this evening.

Thanks, you are correct we do have root access. Just not experienced as DB admins.

Another late night I’m afraid, but I have had a look at your spreadsheet and I have a couple of questions.

Is the data a complete data set for 2017? I guessed it maybe as month 2 has 28 days so its Feb but not Feb 2016.

Where do you want the data to start? if downloaded in complete years it may be best to start with 2016 to avoid waiting to compare to real data, in fact if you have real data for the past few months you could have an instant historical real vs predicted comparison to work with. We will need to start at the earliest date as we will not be able to insert earlier data once the feed is initiated.

Is the data raw as it is downloaded? The timestamping is an odd format with month, day and hour in different columns which makes it a bit of a messy formula to achieve a unix timestamp.

Do you want all the fields included? that would require 8 feed files and I think that maybe using the bulk upload would be better than manipulating 8 data files, 8 meta files, the mySQL entries and redis manually.

I have attached your spreadsheet that I converted to an excel file to convert the dates, on the right you will see a unixtimestamp column followed by node id (I chose 4 for now but it can be changed) and the same 8 original fields in the same order. This newly formatted and unlabeled data I put in a plain csv file, also attached.

You can see that file could very easily be parsed and sent to emoncms for normal log to feed processing. emonhub (original) is geared up the task so do you have another pi or pc you could run emonhub on?

Using 8x phptimeseries feeds, which are 9bytes per datapoint, each year would use less than 0.7MB, phpfina would use half the space and is better suited to the task ( faster graphing etc) but has the 48hr restriction. (perhaps we could try relaxing that restriction temporarily?). Using emonhub with a 250frame per 10sec limit it should take less than 6mins to post each years data

pvwatts_hourly.csv (407.3 KB)

pvwatts_hourly.xlsx.txt (1.3 MB) (remove the ".txt"save as a “.xlsx”)

here’s a snippet of the csv file opened with a test editor rather than excel

The first 2 values are Unix Timestamp and NodeId then Beam Irradiance, Diffuse Irradiance, Ambient Temperature, Wind Speed, Plane of Array, Irradiance, Cell Temperature, DC Array Output, AC System Output


According to Dark Sky they aggregate data from multiple sources depending on the region. I am simply a user so have little idea of the value of the data per se - just it was a convenient “free” source for per-hour cloud cover forecasts for my location (London).

Looks like the lion’s share of the data is from NOAA (NWS) with the balance coming from the UK, Norway and Canada.

A bit further down on that page is the following list:

Data Sources:
1.Dark Sky’s own hyperlocal precipitation forecasting system (id darksky), backed by radar data from the following systems:◦The USA NOAA’s NEXRAD system (USA).
◦The UK Met Office’s NIMROD system (UK, Ireland).
◦(More coming soon.)

2.The USA NOAA’s LAMP system (USA, id lamp).
3.The UK Met Office’s Datapoint API (UK, id datapoint).
4.The Norwegian Meteorological Institute’s meteorological forecast API (global, id metno).
5.The USA NOAA’s Global Forecast System (global, id gfs).
6.The USA NOAA’s Integrated Surface Database (global, id isd).
7.The USA NOAA’s Public Alert system (USA, id nwspa).
8.The UK Met Office’s Severe Weather Warning system (UK, id metwarn).
9.Environment Canada’s Canadian Meteorological Center ensemble model (global, id cmc).
10.The US Navy’s Fleet Numerical Meteorology and Oceanography Ensemble Forecast System (global, id fnmoc).
11.The USA NOAA and Environment Canada’s North American Ensemble Forecast System (global, id naefs).
12.The USA NOAA’s North American Mesoscale Model (North America, id nam).
13.The USA NOAA’s Rapid Refresh Model (North America, id rap).
14.The Norwegian Meteorological Institute’s GRIB file forecast for Central Europe (Europe, id metno_ce).
15.The Norwegian Meteorological Institute’s GRIB file forecast for Northern Europe (Europe, id metno_ne).
16.Worldwide METAR weather reports (global, id metar).
17.The USA NOAA/NCEP’s Short-Range Ensemble Forecast (North America, id sref).
18.The USA NOAA/NCEP’s Real-Time Mesoscale Analysis model (North America, id rtma).
19.The USA NOAA/ESRL’s Meteorological Assimilation Data Ingest System (global, id madis).

So I had a bash at this today and successfully created both phpfina and phptimeseries feeds for each of the 8 variables by using the pre-formatted csv file attached to my last post and a simple bash script.

Firstly though I used the input api to create some inputs so I could then create the process lists including setting up the feeds. For each input I added a log to feed - phptimeseries and also a phpfina with a 1hour interval.

For the phpfina feed to work beyond the 48hr restiction I also edited that “48hr” line in the feed engine code to a more liberal 1000 days temporarily $end = $now+(3600*48*500); and restarted apache2.

Then just ran the attached script firstly on a small subset, then on the remainder. It only took a couple of minutes and it was done, all 8760 frames (70080 datapoints).

Here is a snippet of screen output, it is the final 2 batches so only the first is a full batch of 100 frames. (I’ve edited out my apikey though).

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100     2  100     2    0     0      1      0  0:00:02  0:00:01  0:00:01     1

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100     2  100     2    0     0      5      0 --:--:-- --:--:-- --:--:--     5

Here is a screenshot of the feeds page showing the data sizes which appear correct (8760x9bytes=78840 /1024=76.99kB & 8760x4bytes=35040 /1024=32.21kB)

If you have a file for 2016 start with using the formula in the speadsheet I posted to get a pure csv file (watch out for windows/unix line-endings), or give me the file and I will convert it for you.

I’ve attached the script which you will need to edit for your own apikey etc but running the script is the final step, the feeds and the csv all need to be setup first. There is little or no error checking (and I should add some comments too) so you must fully prepare before running it. (969 Bytes)

fancy giving it a go?


Haven’t had the chance to try this out yet and it’s our summer intern Berkeley’s last week so I don’t know if we’ll get around to it before he goes. However, we got some awesome data yesterday with the existing implementation correlating with cloud cover. As you can see in the graph below, when the cloud forecast surpasses 0.6 the irradiance becomes spotty and when cloud cover approaches 0.9 it drops to less than 30% nominal output. Pretty cool!

Cloud cover is graphed in blue and scaled 0 to 1 on the left hand side. All other units are in Watts 0 to 2000

1 Like

I realise this thread is 3 year old, but this looks really interesting! I need to figure out a solar forecast for the DemandShaper module Emoncms Demand Shaper module - #24 by Rjallan21 are any of you still using the procedure described above? was there any more development on this? Ideally Id like to implement this as a script that produces the forecast for a given location, did anyone take that approach rather than using node red?

1 Like

Haven’t made any changes or progress on this since we implemented it. Curious to see if anyone else has advanced it further.

1 Like

thanks @SolarMill

There is a very useful solar forecasting tool that has been developed out of research at the Australian National University, and commercialised by Solcast. It can provide a solar forecast for any location.

They say “Solcast can forecast solar data for any location on Earth. Using five weather satellites and a growing suite of numerical weather models, Solcast generates over 600 million actual and forecast data points every hour.”

“For the majority of locations, Solcast Live and Forecast data is updated every 10 to 15 minutes at a resolution of 1 to 2 km.”

While primarily for large & commercial PV installation, home rooftop systems can access some services for free.

There is a “tuning” system available where machine learning is used on historical data, so forecasts can be more accurate. I was looking to use the forecast/tuning
facility but my system is setup with variable (manual) export limiting so not suitable for this.