Weather files are getting "time shifted" by 8 hours from download script

  • Kyle Dean
  • Topic Author
More
25 Jan 2023 15:03 - 25 Jan 2023 15:44 #11868 by Kyle Dean
Hello,

I am attempting to use a .LK script file to download a batch of NSRDB weather files given coordinate input. The script is largely copied from the example available to download from this site.

The timestamps do not make any sense on these files and appear to be timeshifted 8 hours forward. When I do a download of the same weather file from the SAM software interface, the file I get contains the same data but different time stamps. See attached screenshot for side-by-side of output weather files.


 
Last edit: 25 Jan 2023 15:44 by Paul Gilman.

Please Log in or Create an account to join the conversation.

  • Paul Gilman
More
25 Jan 2023 15:46 #11869 by Paul Gilman
Hi Kyle,

SAM expects time stamps to be in local time, so be sure to set the 'utc' parameter to false in your calls to the NSRDB API . Note that if you omit the 'utc' parameter, the API assumes a default value of true.

Best regards,
Paul.

Please Log in or Create an account to join the conversation.

  • Kyle Dean
  • Topic Author
More
26 Jan 2023 08:29 #11873 by Kyle Dean
Paul,

Thank you for the info. Can you tell me how / where in the script I should set the UTC parameter?

Thanks

Please Log in or Create an account to join the conversation.

  • Kyle Dean
  • Topic Author
More
26 Jan 2023 09:19 #11874 by Kyle Dean
Paul,

Never mind on the request, I was able to correct the issue by adding the bolded lines of code to the download script.
Code:
    // get download urls for all available versions, intervals, and years, create     // file names for downloads     for( i=0; i<#links; i++ )     {         if ( year == 'all' )         {             for ( j=0; j<#available_years; j++ )             {                 if ( available_years[j] != 'all' )                 {                     if ( (links[i].year == available_years[j]) && (links[i].interval == interval) )                     {                         if ( strpos(available_years[j], 't') > -1 ) { intvl = 60; } // tmy, tgy, or tdy                         else { intvl = interval; }                         url = links[i].link;                         url = replace( url, 'yourapikey', api_key );                         url = replace( url, 'youremail', api_email );                        [b] url = url+'&utc=false';//add in UTC false parameter to download URL[/b]                         wf.url[n] = url;                         wf.fname[n] = path + '/nsrdb_' + site.name[s] + '_' + site.lat[s] + '_' + site.lon[s] + '_' + intvl + 'min_' + available_years[j] + '.csv';                         n++;                     }                 }                 }             }         elseif ( (links[i].year == year) && (links[i].interval == interval) )         {             url = links[i].link;             url = replace( url, 'yourapikey', api_key );             url = replace( url, 'youremail', api_email );            [b] url = url+'&utc=false'; //add in UTC false parameter to URL[/b]             wf.url[n] = url;             wf.fname[n] = path + '/nsrdb_' + site.name[s] + '_' + site.lat[s] + '_' + site.lon[s] + '_' + interval + 'min_' + year + '.csv';             n++;         }     }

Thanks for the advice.

Kyle D

Please Log in or Create an account to join the conversation.

Moderators: Paul Gilman
Powered by Kunena Forum