generateGranulesIndex.php
1.14 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
<?php
/**
* @file generateGranulesIndex.php
* @brief
* @version $Id: $
*/
require_once 'DDService/DDserverWeb_ini.php';
if (!getenv('DDBASE'))
define('DDBASE', '/data/DDBASE/DATA');
else
define('DDBASE', getenv('DDBASE'));
$ddSys = new DOMDocument('1.0');
$ddSys->load(DDBASE.'/DDsys.xml');
$dataSets = $ddSys->getElementsByTagName('VI');
foreach ($dataSets as $VI)
{
$id = $VI->getElementsByTagName('NAME')->item(0)->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("GRANULES/$id.json", json_encode($main));
}
?>