The general reason for WindGen 3 is that we have not been using the data from the Weibull wind speed distributions correctly. The distributions indicate average hourly wind speed, and we have used them as maximum daily wind speeds. This new version of WindGen is created to use the data correctly. Define array: Weibull Generated hourly Wind speeds, This array has four dimensions, Month, Direction, "week", and hours. The idea is to generate hourly wind speeds, for a each hour of a day, for a week's worth of data. (In our case, a week may be between 2 and 15 days) This array will hold a week's worth of data for each month, for each of the 16 cardinal directions for the month. float hws[month][direction][week][hours] We will implement this four dimensional array as THREE dimensions. float hws[month][direction][hours_period] First, we are now calling our "week" a period, as the length may not be seven days. And we are using three dimensions to facilitate the use of internal routines to perform an initial sort of the hourly wind speeds for the week, prior to placing them into days which contain some semblance to the actual gradual increase and then decrease of wind velocity during a day. The reason for the variable period is to determine how to take the generated hourly wind speeds and place them, not only into appropriate time spots for the day, but to create multi-day storms. Now on to how we will generate, sort and keep this data for use.... When data is in the array, windgen will (for it's current day of the month) generate a random number to indicate the direction for the wind today. This direction/month pair will used to locate a a days worth of data for the windgen simulation. In order to facilitate this look up, we will create a ancillary array of pointers to indicate the next available day's data for each direction/month pair. pointer dailyWindSpeeds[month][direction] points at hws data We will initially not fill the HWS array with data, but fill a "weeks" worth of data as each direction/month is selected. This will give us additional data for this same direction/month the next time it is selected. Initially, out pointers will be set to NULL, and when the last day's worth of data is selected and used, we will reset that pointer to null. dws[month][direction] = hws[month][direction][week+1][0] When windgen requests a day's worth of data. we will: test the pointer to see if data has not been created for this direction/month, then create the data. return data increment the pointer to point to "tomorrow's" data To create the week's worth of data for a direction/month we will: generate from the weibull, 24 hourly values for each day. sort these 24*n values wave our magic wand to try to create some kind of sine wave progression of the data through the day (with max speed based on the database) for each day of the "week" from all the hourly wind speeds generated for that week randomize these days in the week of data. set the pointer to point to the data appropriately. -----------------[ Mar 07 01 ]-------------------- Ok, we're working on the sorting, spreading, and shuffling. We use these terms to indicate: Sorting - self explainatory. Routines are available to sort for the entire period, or to sort each individual day of the period. spreading - this routine is the algorithm that desides how to move group and move sorted (erosive) wind speeds to indididual days. shuffling - routine to place the max wind speed for the day at the max hour for the day as indicated by the data base. Original routine written by Larry Wagner for wind_gen2 We will implement Larry's shuffling method simply as he created it. Later, we may consider making this a set of pointers (24 hours worth to contain a entire day) as each day of the period will have the same hour for max wind speed. Or, as we pull hours from the sorted period, spreading them to individual days, we may, instead of inserting them in an simple ordered fashion in the selected day, insert them shuffled around this hour of maximum wind speed - in effect combining the spread and shuffle routines. - I am wondering a bit whether the idea of different durations of storms based on the wind velocity is s good idea. The current thought is : Wind Velocity | Number of hours of wind speed over this velocity will constitute a storm ===============+============ 20 | 1 18 | 2 15 | 3 12 | 4 10 | 5 8 | 6 Or something like that. There may be some variability that we want to "build in" such as "if we have 4 to 8 wind velocities over 8 meters per second, we can have a storm" I think we're trying to un-sort the randomness of the data a bit too much here. As we're not implementing this yet, It's not an enormous concern. invocation: wind_gen3 ~/work/climate/wind_gen/src/bin>wind_gen3 -f ../../db/wind_gen.wdb -s 13981 -l > myfile.txt This is for some Alaska station with a high percentage of CALM wind_gen3 -f ../../db/wind_gen.wdb -s 26410 -l -D > myfile.txt committing with a command line reason Why.... chepil:>cvs commit -m "Adding parameters for buildStorm" windgen3.h ZERO wind speeds.... Need to start inserting the zero wind speeds into the data. Probably should just make the if statement which selects cor calm, a while loop instead. "while rnd1 > dirf..." and just toss the calm's generated randomly this way, rather than try to re-scale the scale for the direction percentages. (Good number of zeros won't be recognizable until days are randomized. as all zeros will sort, spread and shuffle towards latter days in period) (tested with Alaska with ~35 percent calm hours in year. Seemed close.) Shuffle: hacked from Larry's code. Issue: LEW used "WS_DAY" and "HRS_DAY" compiler directives, both set to 24, Well I think my HOURS_DAY corresponds to LEW's WS_DAY, and I did nothing about HRS_DAY, which Is used I suppose if you don't want the hourly wind speed for for 24 hours in a day, but for some other number of hours... The flag -d indicated the number of days (up to a maximum of 7) for which to generate the hourly wind speeds. Hourly wind speeds for 24*d hours are created. The flag -u indicates the "dUration of a storm" and is parameterized by an integer indicating the number of hours to take from the sorted hourly wind speed array and place into each day's windspeeds. The highest u windspeeds are placed in to the first day. The next high u windspeeds are placed in the second day, and so on up to the d days in the period. The range of u is from 1 to 24. Someone has stated that a reasonable storm is 6 to 8 hours in length. The default value is six (6) The program can be called as follows: wind_gen3 -f wind_gen.wdb -s 26410 -d 4 -u 8 -o outputfile.txt where the WBAN station can be set with the -s flag and the output file is set with the -o flag char *optstring = "DlVvhf:o:s:x:r:b:y:d:u:?";