Commit 4d59071c7180b066b95722208364ead8b2af60aa

Authored by Elena.Budnik
1 parent 7d7445ea

https://gitlab.irap.omp.eu/CDPP/CDF_tools/commit/c9ab9b8d233d16c76f6c51838461c7a18346d4ed

src/DDSERVICES/REST/get_cdf.php
... ... @@ -14,7 +14,7 @@ if (!$_GET['id']) {
14 14  
15 15 require_once './DDserverWeb_ini.php';
16 16  
17   -$name = preg_replace('/\..*/', '', $_GET['id']); // ie. ACE/SW/sw19980204
  17 +$name = preg_replace('/(.*\/.*\/.*)(\..*)/', '${1}', $_GET['id']); // ie. ACE/SW/sw19980204
18 18 $inputFilePath = baseDir . $name . '.nc.gz'; // ie. /data/DDBASE/DATA/ACE/SW/sw19980204.nc.gz
19 19 $outputFilePath = $tmpDir . str_replace('/', '_', $name) . '.cdf'; // ie. /tmp/ACE_SW_sw19980204.cdf
20 20  
... ...
src/DDSERVICES/REST/nc2cdf.py
... ... @@ -14,10 +14,13 @@ os.environ['SPACEPY'] = '/tmp'
14 14 import netCDF4
15 15 from spacepy import pycdf
16 16  
17   -AMDA_DICT_PATH = './amda.json'
18 17 TEMP_FILE = '/tmp'
19 18  
20 19  
  20 +
  21 +RESOLVER_URL = 'http://apus.irap.omp.eu:8080/amda-registry/resolver'
  22 +
  23 +
21 24 def error(error_message, e=None):
22 25 """ Display an `error_message` and exit the program. """
23 26  
... ... @@ -140,10 +143,20 @@ class NetCdf:
140 143  
141 144 # Make the pyCDF object
142 145 try:
143   - return pycdf.CDF(cdf_path, '')
  146 + cdf = pycdf.CDF(cdf_path, '')
144 147 except pycdf.CDFError as e:
145 148 error('Can not create CDF file on %s, check that the directory exists and its writing access' % cdf_path, e)
146 149  
  150 + # TODO Get spase file
  151 +
  152 + get_spase()
  153 +
  154 + cdf.attrs['Acknowledgement '] = 'John Doe'
  155 +
  156 + return cdf
  157 +
  158 + def get_spase(self):
  159 +
147 160 @staticmethod
148 161 def build_temp_path(path, extension):
149 162 return op.abspath(op.join(TEMP_FILE, op.basename(path).split('.')[0] + extension))
... ...