Commit 7d539a8c1b98a7b2a1c90d95a08c3c526be2c89b

Authored by Elena.Budnik
1 parent 73625886

server side modifs

php/classes/FilesMgr.php
@@ -120,15 +120,21 @@ class FilesMgr extends AmdaObjectMgr @@ -120,15 +120,21 @@ class FilesMgr extends AmdaObjectMgr
120 return array('type' => $data_type, 'size' => $size, 'n_records' => $n_recs, 'units' => $units, 'fillvalue' => $fillval); 120 return array('type' => $data_type, 'size' => $size, 'n_records' => $n_recs, 'units' => $units, 'fillvalue' => $fillval);
121 } 121 }
122 122
123 - public function getCdfSampling()  
124 - { 123 + public function getCdfSampling() {
125 copy($this->fileName, "temp.cdf"); 124 copy($this->fileName, "temp.cdf");
126 exec('cdfsamplingfromdata ', $results); 125 exec('cdfsamplingfromdata ', $results);
127 unlink("temp.cdf"); 126 unlink("temp.cdf");
128 127
129 return $results; 128 return $results;
130 } 129 }
  130 +
  131 + public function getCdfSamplings() {
  132 + copy($this->fileName, "temp.cdf");
  133 + exec('cdfsamplingsfromdata ', $results);
  134 + unlink("temp.cdf");
131 135
  136 + return $results;
  137 + }
132 /* 138 /*
133 * CEF format processing 139 * CEF format processing
134 */ 140 */
@@ -594,22 +600,30 @@ class FilesMgr extends AmdaObjectMgr @@ -594,22 +600,30 @@ class FilesMgr extends AmdaObjectMgr
594 } 600 }
595 601
596 602
597 - protected function createFile($format) 603 + protected function createFile($format, $samplingType)
598 { 604 {
599 $newFile = $this->contentDom->createElement('file'); 605 $newFile = $this->contentDom->createElement('file');
600 $newFile->setAttribute('xml:id', $this->fileId); 606 $newFile->setAttribute('xml:id', $this->fileId);
601 $newFile->setAttribute('name', $this->fileId); 607 $newFile->setAttribute('name', $this->fileId);
602 $newFile->setAttribute('format', $format); 608 $newFile->setAttribute('format', $format);
603 - 609 +
  610 + $minSamp = $this->sampling;
  611 + $maxSamp = $this->maxSampling;
  612 +
604 switch ($format) 613 switch ($format)
605 { 614 {
606 case "cdf": 615 case "cdf":
607 $start_stop = explode(" ",$this->getCdfStartStop()); 616 $start_stop = explode(" ",$this->getCdfStartStop());
608 - $result = $this->getCdfSampling();  
609 - //TODO process errors  
610 - $minSamp = $result[count($result)-1];  
611 - //TODO if min & max  
612 - $maxSamp = $minSamp; 617 + if ($minSamp < 0) {
  618 + if ($samplingType == 'constant') {
  619 + $result = $this->getCdfSampling();
  620 + //TODO process errors
  621 + $minSamp = $result[count($result)-1];
  622 + $maxSamp = $minSamp;
  623 + } else {
  624 + // $result = $this->getCdfSamplings();
  625 + }
  626 + }
613 break; 627 break;
614 case "txt": 628 case "txt":
615 $start_stop = explode(" ",$this->reformatTxt()); 629 $start_stop = explode(" ",$this->reformatTxt());
@@ -621,16 +635,14 @@ class FilesMgr extends AmdaObjectMgr @@ -621,16 +635,14 @@ class FilesMgr extends AmdaObjectMgr
621 // Test if 'standard' meta exist in CEF 635 // Test if 'standard' meta exist in CEF
622 $cefMetaTest = $this->getCefStartStop(); 636 $cefMetaTest = $this->getCefStartStop();
623 637
624 - if ($cefMetaTest != -1)  
625 - { 638 + if ($cefMetaTest != -1) {
626 $cefStartStop = explode("/",$cefMetaTest); 639 $cefStartStop = explode("/",$cefMetaTest);
627 $start_stop[] = strtotime($cefStartStop[0]); 640 $start_stop[] = strtotime($cefStartStop[0]);
628 $start_stop[] = strtotime($cefStartStop[1]); 641 $start_stop[] = strtotime($cefStartStop[1]);
629 $result = $this->getCefSampling(); 642 $result = $this->getCefSampling();
630 $minSamp = $result[count($result)-1]; 643 $minSamp = $result[count($result)-1];
631 } 644 }
632 - else  
633 - { 645 + else {
634 // no META data - so time processing 646 // no META data - so time processing
635 $timeInfo = $this->getCefTimeInfo(); 647 $timeInfo = $this->getCefTimeInfo();
636 $timeInfoArr = explode(" ", $timeInfo); 648 $timeInfoArr = explode(" ", $timeInfo);
@@ -644,8 +656,10 @@ class FilesMgr extends AmdaObjectMgr @@ -644,8 +656,10 @@ class FilesMgr extends AmdaObjectMgr
644 case "vot" : 656 case "vot" :
645 $start_stop = explode(" ",$this->getVotFileMgr()->getStartStop()); 657 $start_stop = explode(" ",$this->getVotFileMgr()->getStartStop());
646 $samplings = $this->getVotFileMgr()->getSamplings(); 658 $samplings = $this->getVotFileMgr()->getSamplings();
647 - $minSamp = $samplings["minSampling"];  
648 - $maxSamp = $samplings["maxSampling"]; 659 + if ($minSamp < 0) {
  660 + $minSamp = $samplings["minSampling"];
  661 + $maxSamp = $samplings["maxSampling"];
  662 + }
649 $desc = $this->getVotFileMgr()->getDescription(); 663 $desc = $this->getVotFileMgr()->getDescription();
650 break; 664 break;
651 case "nc": 665 case "nc":
@@ -655,11 +669,13 @@ class FilesMgr extends AmdaObjectMgr @@ -655,11 +669,13 @@ class FilesMgr extends AmdaObjectMgr
655 return $ncInfo; 669 return $ncInfo;
656 } 670 }
657 $ncInfoArr = explode("#",$ncInfo); 671 $ncInfoArr = explode("#",$ncInfo);
658 - $start_stop = explode(":",$ncInfoArr[0]);  
659 - //TODO process errors  
660 - $minSamp = $ncInfoArr[1];  
661 - //TODO if min & max  
662 - $maxSamp = $minSamp; 672 + $start_stop = explode(":",$ncInfoArr[0]);
  673 + if ($minSamp < 0) {
  674 + //TODO process errors
  675 + $minSamp = $ncInfoArr[1];
  676 + //TODO if min & max
  677 + $maxSamp = $minSamp;
  678 + }
663 break; 679 break;
664 default: 680 default:
665 } 681 }
@@ -1128,20 +1144,27 @@ class FilesMgr extends AmdaObjectMgr @@ -1128,20 +1144,27 @@ class FilesMgr extends AmdaObjectMgr
1128 1144
1129 $format = $this->getFormat(); 1145 $format = $this->getFormat();
1130 1146
1131 - if ($format === 'unknown')  
1132 - { 1147 + if ($format === 'unknown') {
1133 unlink($this->fileName); 1148 unlink($this->fileName);
1134 return array('success' => false, 'error' => 'Sorry, unknown format of '.$fileName); 1149 return array('success' => false, 'error' => 'Sorry, unknown format of '.$fileName);
1135 } 1150 }
1136 1151
  1152 + // if sampling is defined by user
  1153 + if ($formats["samplingType"] == "manual") {
  1154 + $this->sampling = $formats["min_sampling"];
  1155 + if ($formats["max_sampling"])
  1156 + $this->maxSampling = $formats["max_sampling"];
  1157 + else
  1158 + $this->maxSampling = $this->sampling;
  1159 + }
  1160 +
  1161 +
1137 if ($format == 'txt') 1162 if ($format == 'txt')
1138 { 1163 {
1139 - if ($formats["timeFormat"] == "user")  
1140 - { 1164 + if ($formats["timeFormat"] == "user") {
1141 $res = $this->reformatTime($formats["nonStandard"], $formats["timeLength"], $formats["doy"]); 1165 $res = $this->reformatTime($formats["nonStandard"], $formats["timeLength"], $formats["doy"]);
1142 1166
1143 - if (!$res)  
1144 - { 1167 + if (!$res) {
1145 unlink($this->fileName); 1168 unlink($this->fileName);
1146 return array('success' => false, 'error' => 'can\'t reformat time'); 1169 return array('success' => false, 'error' => 'can\'t reformat time');
1147 } 1170 }
@@ -1149,60 +1172,54 @@ class FilesMgr extends AmdaObjectMgr @@ -1149,60 +1172,54 @@ class FilesMgr extends AmdaObjectMgr
1149 // check if file is not empty 1172 // check if file is not empty
1150 $vars = $this->getTxtColNumber(false); 1173 $vars = $this->getTxtColNumber(false);
1151 1174
1152 - if ($vars == -100)  
1153 - { 1175 + if ($vars == -100) {
1154 return array('success' => false, 'error' => 'no such file'); 1176 return array('success' => false, 'error' => 'no such file');
1155 } 1177 }
1156 1178
1157 - if ($vars == -1)  
1158 - { 1179 + if ($vars == -1) {
1159 unlink($this->fileName); 1180 unlink($this->fileName);
1160 return array('success' => false, 'error' => 'while reading file'); 1181 return array('success' => false, 'error' => 'while reading file');
1161 } 1182 }
1162 1183
1163 - if ($vars === 0)  
1164 - { 1184 + if ($vars === 0) {
1165 unlink($this->fileName); 1185 unlink($this->fileName);
1166 return array('success' => false, 'error' => 'file contains no data'); 1186 return array('success' => false, 'error' => 'file contains no data');
1167 } 1187 }
  1188 +
  1189 + // sampling is to be defined automatically
  1190 + if ($this->sampling < 0) {
  1191 + if ($formats["timeSampling"] == "constant") {
  1192 + $this->sampling = $this->getTxtSampling();
  1193 + $this->maxSampling = $this->sampling;
  1194 + }
  1195 + else {
  1196 + $samplings = $this->getTxtSamplings();
  1197 + $this->sampling = $samplings[0];
  1198 + $this->maxSampling = $samplings[1];
  1199 + }
1168 1200
1169 - if ($formats["timeSampling"] == "constant")  
1170 - {  
1171 - $this->sampling = $this->getTxtSampling();  
1172 - $this->maxSampling = $this->sampling;  
1173 - }  
1174 - else  
1175 - {  
1176 - $samplings = $this->getTxtSamplings();  
1177 - $this->sampling = $samplings[0];  
1178 - $this->maxSampling = $samplings[1]; 1201 + if ($this->sampling <= 0) {
  1202 + unlink($this->fileName);
  1203 + if ($this->sampling == -10) {
  1204 + return array('success' => false, 'error' => 'Sorry, can\'t process'.$fileName.PHP_EOL.'. Check if there are non numeric chars in the data');
  1205 + }
  1206 + return array('success' => false, 'error' => 'Sorry, can\'t process Time for '.$fileName.PHP_EOL.'. Check time format, start time (> 1970-01-01) or sampling time (>= 1s)');
  1207 + }
1179 } 1208 }
1180 -  
1181 - if ($this->sampling <= 0)  
1182 - {  
1183 - unlink($this->fileName);  
1184 - if ($this->sampling == -10)  
1185 - {  
1186 - return array('success' => false, 'error' => 'Sorry, can\'t process'.$fileName.PHP_EOL.'. Check if there are non numeric chars in the data');  
1187 - }  
1188 - return array('success' => false, 'error' => 'Sorry, can\'t process Time for '.$fileName.PHP_EOL.'. Check time format, start time (> 1970-01-01) or sampling time (>= 1s)');  
1189 - }  
1190 } 1209 }
1191 1210
1192 if ($format == 'nc') 1211 if ($format == 'nc')
1193 { 1212 {
1194 $status = $this->reformatNcTime(); 1213 $status = $this->reformatNcTime();
1195 - if ($status <= 0)  
1196 - { 1214 + if ($status <= 0) {
1197 unlink($this->fileName); 1215 unlink($this->fileName);
1198 return array('success' => false, 'error' => 'error '.$timeFormat.PHP_EOL.'Time Format problem'); 1216 return array('success' => false, 'error' => 'error '.$timeFormat.PHP_EOL.'Time Format problem');
1199 } 1217 }
1200 } 1218 }
1201 1219
1202 //create new file tag with all attributes and add it to the content DOM 1220 //create new file tag with all attributes and add it to the content DOM
1203 - $newFile = $this->createFile($format);  
1204 - if (is_int($newFile) && ($newFile < 0))  
1205 - { 1221 + $newFile = $this->createFile($format, $formats["timeSampling"]);
  1222 + if (is_int($newFile) && ($newFile < 0)) {
1206 unlink($this->fileName); 1223 unlink($this->fileName);
1207 return array( 'success' => false, 'file' => $fileName); 1224 return array( 'success' => false, 'file' => $fileName);
1208 } 1225 }
@@ -1218,8 +1235,8 @@ class FilesMgr extends AmdaObjectMgr @@ -1218,8 +1235,8 @@ class FilesMgr extends AmdaObjectMgr
1218 $mask->appendChild($newFile); 1235 $mask->appendChild($newFile);
1219 1236
1220 $files = $mask->getElementsByTagName("file"); 1237 $files = $mask->getElementsByTagName("file");
1221 - foreach ($files as $file)  
1222 - { 1238 +
  1239 + foreach ($files as $file) {
1223 $starts[] = $file->getAttribute("start"); 1240 $starts[] = $file->getAttribute("start");
1224 $stops[] = $file->getAttribute("stop"); 1241 $stops[] = $file->getAttribute("stop");
1225 } 1242 }
@@ -1230,8 +1247,7 @@ class FilesMgr extends AmdaObjectMgr @@ -1230,8 +1247,7 @@ class FilesMgr extends AmdaObjectMgr
1230 } 1247 }
1231 } 1248 }
1232 // no corresponding masks => add to fileList 1249 // no corresponding masks => add to fileList
1233 - if (!$isMask)  
1234 - { 1250 + if (!$isMask) {
1235 $filesList = $this->contentDom->getElementById($this->contentRootId); 1251 $filesList = $this->contentDom->getElementById($this->contentRootId);
1236 $filesList->appendChild($newFile); 1252 $filesList->appendChild($newFile);
1237 } 1253 }
@@ -1241,8 +1257,7 @@ class FilesMgr extends AmdaObjectMgr @@ -1241,8 +1257,7 @@ class FilesMgr extends AmdaObjectMgr
1241 //if mask exists - add to data base 1257 //if mask exists - add to data base
1242 $myBaseManager = new BaseManager(); 1258 $myBaseManager = new BaseManager();
1243 $mask = $myBaseManager->addFile($fileName); 1259 $mask = $myBaseManager->addFile($fileName);
1244 - if ($mask != null)  
1245 - { 1260 + if ($mask != null) {
1246 $startstop = $myBaseManager->getStartStop($myBaseManager->getVi($mask)); 1261 $startstop = $myBaseManager->getStartStop($myBaseManager->getVi($mask));
1247 $myParamMgr = new DerivedParamMgr('myDataParam'); 1262 $myParamMgr = new DerivedParamMgr('myDataParam');
1248 $myParamMgr->updateMydata($mask,$startstop); 1263 $myParamMgr->updateMydata($mask,$startstop);
php/src/cdfsamplingfromdata.c
1 -/* $Id: timeResFromData.c,v 1.1 2010/08/31 10:32:55 budnik Exp $ */ 1 +/* $Id: cdf constant samplig from data $ */
2 2
3 -/** @file timeResFromData.c  
4 -* @brief Function to get CDAWEB dataset sampling times from data files  
5 -*/  
6 #include <stdio.h> 3 #include <stdio.h>
7 #include <stdlib.h> 4 #include <stdlib.h>
8 #include <cdf.h> 5 #include <cdf.h>
@@ -46,48 +43,18 @@ void cdf_handle_error(CDFstatus status) @@ -46,48 +43,18 @@ void cdf_handle_error(CDFstatus status)
46 exit(1); 43 exit(1);
47 } 44 }
48 45
49 -void find_min(int* delta, int nRecs, int minFalse, int* minVal)  
50 -{  
51 - int i, n, min;  
52 -  
53 - n = 1;  
54 - i = 0;  
55 - while (abs(delta[i]) <= minFalse) i++;  
56 - if (i < nRecs) {  
57 - min = abs(delta[i]);  
58 - // printf(" first MIN %d \n", min);  
59 - for (i = 1; i < nRecs; i++) {  
60 - // printf(" delta %d \n", delta[i]);  
61 - if (delta[i] == min) n++;  
62 - if (delta[i] < min && delta[i] > minFalse) {  
63 - min = delta[i];  
64 - n = 1;  
65 - }  
66 - }  
67 - } else {  
68 - min = -10;  
69 - n = nRecs;  
70 - }  
71 -  
72 - minVal[0] = min;  
73 - minVal[1] = n;  
74 - printf(" MIN %d %d\n", min, n);  
75 -}  
76 -  
77 int main(int argc, char *argv[]) 46 int main(int argc, char *argv[])
78 { 47 {
79 - long RecStart = 0, RecCount, RecInt = 1; 48 + long RecStart = 0, RecCount = 2, RecInt = 1;
80 long indices[1] = {0}, intervals[1] = {1}, counts[1] = {1}; 49 long indices[1] = {0}, intervals[1] = {1}, counts[1] = {1};
81 long varN = -1; 50 long varN = -1;
82 long datatype = 0, attrN, maxEntry; 51 long datatype = 0, attrN, maxEntry;
83 CDFstatus cstatus; // CDF status code 52 CDFstatus cstatus; // CDF status code
84 CDFid id; 53 CDFid id;
85 double *value; 54 double *value;
86 - int *delta;  
87 int i, minFalse = 0, numEnough; 55 int i, minFalse = 0, numEnough;
88 - int min[2] = {0, 0};  
89 char attrValue[300]; 56 char attrValue[300];
90 - float Sampling; 57 + int sampling;
91 double epoch16[2], dbl_value, dbl_value_; 58 double epoch16[2], dbl_value, dbl_value_;
92 long year, month, day, hour, minute, sec, msec, mksec, nsec, psec; 59 long year, month, day, hour, minute, sec, msec, mksec, nsec, psec;
93 long long *int_value; 60 long long *int_value;
@@ -106,26 +73,27 @@ int main(int argc, char *argv[]) @@ -106,26 +73,27 @@ int main(int argc, char *argv[])
106 if ((cstatus = CDFlib(SELECT_, zVAR_, varN, 73 if ((cstatus = CDFlib(SELECT_, zVAR_, varN,
107 GET_, zVAR_DATATYPE_, &datatype, NULL_)) != CDF_OK) 74 GET_, zVAR_DATATYPE_, &datatype, NULL_)) != CDF_OK)
108 cdf_handle_error (cstatus); 75 cdf_handle_error (cstatus);
109 - // if (datatype == CDF_EPOCH16) break;  
110 } 76 }
  77 +
111 fprintf(stdout,"DATATYPE %d %d\n", varN, datatype); 78 fprintf(stdout,"DATATYPE %d %d\n", varN, datatype);
112 if ((cstatus = CDFlib(SELECT_, zVAR_, varN, 79 if ((cstatus = CDFlib(SELECT_, zVAR_, varN,
113 GET_, zVAR_MAXREC_, &CDFmaxRec, NULL_)) != CDF_OK) 80 GET_, zVAR_MAXREC_, &CDFmaxRec, NULL_)) != CDF_OK)
114 cdf_handle_error (cstatus); 81 cdf_handle_error (cstatus);
115 82
116 fprintf(stdout,"Max Recs %d\n", CDFmaxRec+1); 83 fprintf(stdout,"Max Recs %d\n", CDFmaxRec+1);
117 - if (CDFmaxRec < 10) { 84 +
  85 + if (CDFmaxRec < 3) {
118 fprintf(stdout," %d\n", badFile); 86 fprintf(stdout," %d\n", badFile);
119 exit (0); 87 exit (0);
120 } 88 }
121 89
122 if ( datatype == CDF_TIME_TT2000 ) { 90 if ( datatype == CDF_TIME_TT2000 ) {
123 - int_value = (long long *) malloc (sizeof(long long) * (CDFmaxRec+1)); 91 + int_value = (long long *) malloc (sizeof(long long) * (RecCount+1));
124 /******************* Get Epoch *************************/ 92 /******************* Get Epoch *************************/
125 if ((cstatus = CDFlib (SELECT_, 93 if ((cstatus = CDFlib (SELECT_,
126 zVAR_, varN, 94 zVAR_, varN,
127 zVAR_RECNUMBER_, RecStart, 95 zVAR_RECNUMBER_, RecStart,
128 - zVAR_RECCOUNT_, CDFmaxRec+1, 96 + zVAR_RECCOUNT_, RecCount + 1,
129 zVAR_RECINTERVAL_, RecInt, 97 zVAR_RECINTERVAL_, RecInt,
130 zVAR_DIMINDICES_, indices, 98 zVAR_DIMINDICES_, indices,
131 zVAR_DIMCOUNTS_, counts, 99 zVAR_DIMCOUNTS_, counts,
@@ -134,12 +102,12 @@ int main(int argc, char *argv[]) @@ -134,12 +102,12 @@ int main(int argc, char *argv[])
134 cdf_handle_error (cstatus); 102 cdf_handle_error (cstatus);
135 } 103 }
136 else { 104 else {
137 - value = (double *)malloc(sizeof(double)* (CDFmaxRec+1)*((datatype == CDF_EPOCH16)+1)); 105 + value = (double *)malloc(sizeof(double)* (RecCount + 1)*((datatype == CDF_EPOCH16)+1));
138 /******************* Get Epoch *************************/ 106 /******************* Get Epoch *************************/
139 if ((cstatus = CDFlib (SELECT_, 107 if ((cstatus = CDFlib (SELECT_,
140 zVAR_, varN, 108 zVAR_, varN,
141 zVAR_RECNUMBER_, RecStart, 109 zVAR_RECNUMBER_, RecStart,
142 - zVAR_RECCOUNT_, CDFmaxRec+1, 110 + zVAR_RECCOUNT_, RecCount + 1,
143 zVAR_RECINTERVAL_, RecInt, 111 zVAR_RECINTERVAL_, RecInt,
144 zVAR_DIMINDICES_, indices, 112 zVAR_DIMINDICES_, indices,
145 zVAR_DIMCOUNTS_, counts, 113 zVAR_DIMCOUNTS_, counts,
@@ -147,46 +115,35 @@ int main(int argc, char *argv[]) @@ -147,46 +115,35 @@ int main(int argc, char *argv[])
147 GET_, zVAR_HYPERDATA_, value, NULL_)) != CDF_OK) 115 GET_, zVAR_HYPERDATA_, value, NULL_)) != CDF_OK)
148 cdf_handle_error (cstatus); 116 cdf_handle_error (cstatus);
149 } 117 }
150 -  
151 118
152 -  
153 - delta = (int *)malloc(sizeof(int)* CDFmaxRec);  
154 - for (i = 1; i < CDFmaxRec+1; i++)  
155 - { 119 +
156 if (datatype == CDF_TIME_TT2000) { 120 if (datatype == CDF_TIME_TT2000) {
157 - dbl_value_ = CDF_TT2000_to_UTC_EPOCH(int_value[i-1]);  
158 - dbl_value = CDF_TT2000_to_UTC_EPOCH(int_value[i]);  
159 - delta[i-1] = (int)(dbl_value - dbl_value_ + 50)/100; 121 + dbl_value_ = CDF_TT2000_to_UTC_EPOCH(int_value[0]);
  122 + dbl_value = CDF_TT2000_to_UTC_EPOCH(int_value[1]);
  123 + sampling = (int)(dbl_value - dbl_value_ + 50)/100;
160 } 124 }
161 else { 125 else {
162 if (datatype == CDF_EPOCH16) { 126 if (datatype == CDF_EPOCH16) {
163 - epoch16[0] = value[2*(i-1)];  
164 - epoch16[1] = value[2*(i-1)+1]; 127 + epoch16[0] = value[0];
  128 + epoch16[1] = value[1];
165 EPOCH16breakdown(epoch16, &year, &month, &day, &hour, &minute, &sec, &msec, &mksec, &nsec, &psec); 129 EPOCH16breakdown(epoch16, &year, &month, &day, &hour, &minute, &sec, &msec, &mksec, &nsec, &psec);
166 - value[i-1] = computeEPOCH(year, month, day, hour, minute, sec, msec);  
167 - epoch16[0] = value[2*i];  
168 - epoch16[1] = value[2*i+1]; 130 + value[0] = computeEPOCH(year, month, day, hour, minute, sec, msec);
  131 + epoch16[0] = value[2];
  132 + epoch16[1] = value[3];
169 EPOCH16breakdown(epoch16, &year, &month, &day, &hour, &minute, &sec, &msec, &mksec, &nsec, &psec); 133 EPOCH16breakdown(epoch16, &year, &month, &day, &hour, &minute, &sec, &msec, &mksec, &nsec, &psec);
170 - value[i] = computeEPOCH(year, month, day, hour, minute, sec, msec); 134 + value[1] = computeEPOCH(year, month, day, hour, minute, sec, msec);
171 } 135 }
172 - delta[i-1] = (int)(value[i] - value[i-1] + 50)/100; 136 + sampling = (int)(value[1] - value[0] + 50)/100;
173 } 137 }
174 - } 138 +
175 // fprintf(stdout,"value %f\n", value[11]-value[10]); 139 // fprintf(stdout,"value %f\n", value[11]-value[10]);
176 if (datatype == CDF_TIME_TT2000) free(int_value); 140 if (datatype == CDF_TIME_TT2000) free(int_value);
177 else free(value); 141 else free(value);
178 - // fprintf(stdout,"delta %d\n", delta[0]);  
179 - numEnough = CDFmaxRec/10;  
180 - while (min[1] < numEnough) {  
181 - fprintf(stdout,"minFalse %d\n", minFalse);  
182 - find_min(delta, CDFmaxRec, minFalse, min);  
183 - minFalse = min[0];  
184 - } 142 +
185 143
186 - free(delta);  
187 if ((cstatus = CDFlib(CLOSE_, CDF_, NULL_)) != CDF_OK) 144 if ((cstatus = CDFlib(CLOSE_, CDF_, NULL_)) != CDF_OK)
188 cdf_handle_error (cstatus); 145 cdf_handle_error (cstatus);
189 146
190 // fprintf(stdout,"%d %f\n",min[1], (float)min[0]/100.0); 147 // fprintf(stdout,"%d %f\n",min[1], (float)min[0]/100.0);
191 - fprintf(stdout,"%f\n",(float)min[0]/10.0); 148 + fprintf(stdout,"%f\n",(float)sampling/10.0);
192 } 149 }
php/uploadFile.php
@@ -117,11 +117,23 @@ @@ -117,11 +117,23 @@
117 $nonStd = $_POST['nonstd'] ? $_POST['nonstd'] : null; 117 $nonStd = $_POST['nonstd'] ? $_POST['nonstd'] : null;
118 $timeLength = $_POST['timelength'] ? $_POST['timelength'] : null; 118 $timeLength = $_POST['timelength'] ? $_POST['timelength'] : null;
119 $doy = isset($_POST['doy']) ? $_POST['doy'] : null; 119 $doy = isset($_POST['doy']) ? $_POST['doy'] : null;
  120 + $sampling = isset($_POST['smpl']) ? $_POST['smpl'] : null;
  121 + $min_sampling = isset($_POST['min_manual_sampling']) ? $_POST['min_manual_sampling'] : null;
  122 + $max_sampling = isset($_POST['max_manual_sampling']) ? $_POST['max_manual_sampling'] : null;
  123 +
  124 + if ($sampling == "auto" && $timeSmplg == "variable"
  125 + && (strtolower($fileFrmt) == "cdf" || strtolower($fileFrmt) == "nc")) {
  126 + $response = array('success' => false, 'error' => " : Auto-definition of variable sampling for $fileFrmt isn't implemented yet.
  127 + Use manual sampling definition");
  128 + die(json_encode($response));
  129 + }
  130 +
120 $sampData = isset($_POST['sampData']) ? $_POST['sampData'] : null; 131 $sampData = isset($_POST['sampData']) ? $_POST['sampData'] : null;
121 $sampFileName = isset($_POST['sampFileName']) ? $_POST['sampFileName'] : null; 132 $sampFileName = isset($_POST['sampFileName']) ? $_POST['sampFileName'] : null;
122 133
123 $allFormats = array('fileFormat' => $fileFrmt, 'timeFormat' => $timeFrmt, 'doy' => $doy, 134 $allFormats = array('fileFormat' => $fileFrmt, 'timeFormat' => $timeFrmt, 'doy' => $doy,
124 - 'timeSampling' => $timeSmplg, 'nonStandard' => $nonStd, 'timeLength' => $timeLength); 135 + 'timeSampling' => $timeSmplg, 'nonStandard' => $nonStd, 'timeLength' => $timeLength,
  136 + 'samplingType' => $sampling, 'min_sampling' => $min_sampling, 'max_sampling' => $max_sampling);
125 137
126 if ($_POST['filesrc'] == 'URL') $fromURL = true; 138 if ($_POST['filesrc'] == 'URL') $fromURL = true;
127 else $fromURL = false; 139 else $fromURL = false;