generateGranulesIndex.php
1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
/**
* @file generateGranulesIndex.php
* @brief
* @version $Id: $
*/
define('BASE','/data/DDBASE/');
require_once BASE.'DDService/DDserverWeb_ini.php';
if (!getenv('DDBASE'))
define('DDBASE', BASE.'DATA');
else
define('DDBASE', getenv('DDBASE'));
$ddSys = new DOMDocument('1.0');
$ddSys->load(DDBASE.'/DDsys.xml');
$dataSets = $ddSys->getElementsByTagName('VI');
foreach ($dataSets as $VI)
{
$vi_ = $VI->getElementsByTagName("NAME")->item(0);
// only local bases
if ($vi_->getAttribute("base") != "LOCAL") continue;
$id = $vi_->nodeValue;
$main = array();
$index = array();
$location = $VI->getElementsByTagName("LOCATION")->item(0)->nodeValue;
foreach (glob($location."*.nc.gz") as $granule)
{
$cmd = 'stat --printf="%s" '. $granule;
$file = basename($granule,".nc.gz");
$index[$file] = exec($cmd);
}
$main[substr($location,strlen(DDBASE))] = $index;
file_put_contents(BASE."GRANULES/$id.json", json_encode($main));
}
?>