Commit a5d4e666 authored by Erol Cromwell's avatar Erol Cromwell
Browse files

Update check for leap year

parent d43cabc9
......@@ -103,7 +103,6 @@ int yymmdd_to_juldate(int yymmdd)
int i;
int leapyear;
int yy, mm, dd;
int remainder;
int jday = 0;
/* Non-leap year days per month */
......@@ -116,13 +115,11 @@ int yymmdd_to_juldate(int yymmdd)
dd = yymmdd % 100;
/* Determine if is this a leap year*/
remainder = yy % 4;
leapyear = remainder == 0;
leapyear = ISLEAP(yy);
/* Add day to February for leap year*/
if (leapyear) days_per_month[1]+=1;
/* Count number of days */
for (i=1; i<mm; i++) {
jday += days_per_month[i-1];
......@@ -162,6 +159,17 @@ double airmass(double zeta)
*
* Inputs:
*******************************************************************************/
/**
* Run barnard langley algorithm on data
*
* @param D pointer to the input BW DATA structure
* @param gNomCal Nominal calibration factors for channels
* @param start_time Start time of interval
* @param end_time End time time of interval
*
* @retval Pointer to the output BW Data structure
*/
DATA* barnard_langley(DATA *D, float *gNomCal, long start_time, long end_time)
{
DATA *newD;
......@@ -429,10 +437,13 @@ DATA* barnard_langley(DATA *D, float *gNomCal, long start_time, long end_time)
else {
// This means we have a broadband channel in seperate
// field, and tack it onto the front
dvalue = D->BWdata[B1][o][0][IN_BROADBAND][i][0];
lnI[0][n] = D->BWdata[B1][o][0][IN_BROADBAND][i][0] > 0 ?
log(D->BWdata[B1][o][0][IN_BROADBAND][i][0] /
efactor) : -9999;
if (dvalue > 0.0) {
lnI[0][n] = log(dvalue/efactor);
} else {
lnI[0][n] = -9999;
}
}
/* narrowband channels */
......
......@@ -27,6 +27,14 @@
#define MISSING -9999.0
/* Whether a year is a leap year */
#define ISLEAP(y) (y<1900 \
? ((((y+1900) % 4) == 0 && ((y+1900) % 100) != 0) \
|| ((y+1900) % 400) == 0) \
: ((((y) % 4) == 0 && ((y) % 100)) !=0 || ((y) % 400) == 0))
/*
* Really should have number of narrow and number of broad band channels,
* and have a narrow_idx[*] and a broad_idx[*] and work off of the idxs.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment