Adam
unread,Apr 11, 2012, 7:52:03 AM4/11/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to NPP satellite
Hi
The RDR files we generate here at our SCISYS X/L band station at SMHI,
Norrköping, all have orbit number equals 1, both in the filename and
in the attributes in the hdf5 file. This is apparently a bug in the
NASA/DRL RT-STPS software. This software is used to go from the raw
CADU to the level 0 RDR files.
Do you know more about this bug and when it will be fixed?
In the mean time we elaborated a little bit with h5py to make a small
program to fix this afterwards. I use pyorbital from pytroll to get
the orbit number from the observation times, and I get the observation
times (of the granules) by scanning the hdf5 file. It is quite easy.
Below is the hdf5 code to fix the file. It not difficult (thanks to
Martin reminding me that you don't have to copy the entire file
content, you can just change the relevant attributes in the h5py file
object).
But despite the fact that the file looks exactly as the origin (except
of course for the changed orbit number) it is not anymore liked by
CSPP. I used hdfview and h5dump to look at the file content. This is
the error message from CSPP:
INFO:adl_geo_ref:GEO file
GIMGO_npp_d20120405_t0049586_e0051227_b00001_c20120408194840733101_cspp_dev.h5
belongs to /data/proj6/safutv/cspp_test2/work/
SVI04_npp_d20120405_t0049586_e0051227_b00001_c20120411074624762365_cspp_dev.h5
Traceback (most recent call last):
File "/data/proj/safutv/cspp_test2/CSPP3.1/viirs/sdr/
adl_viirs_sdr.py", line 613, in <module>
sys.exit(main())
File "/data/proj/safutv/cspp_test2/CSPP3.1/viirs/sdr/
adl_viirs_sdr.py", line 609, in main
return viirs_sdr( work_dir, args.filenames )
File "/data/proj/safutv/cspp_test2/CSPP3.1/viirs/sdr/
adl_viirs_sdr.py", line 542, in viirs_sdr
add_geo_attribute_to_h5(work_dir, granules_to_process)
File "/data/proj/safutv/cspp_test2/CSPP3.1/viirs/sdr/
adl_viirs_sdr.py", line 445, in add_geo_attribute_to_h5
to_convert = list(get_created_blobs_list(work_dir,
granules_to_process, skim_dir(work_dir,
N_Collection_Short_Name=short_name)))
File "/data/proj/safutv/cspp_test2/CSPP3.1/viirs/sdr/
adl_viirs_sdr.py", line 423, in get_created_blobs_list
pa = it['BlobPath']
KeyError: 'BlobPath'
OOPS: VIIRS SDR did not complete without errors
Anyone having good ideas?
Best regards
Adam
============================
def fix_nppfile4orbitnumber(orbits, npp_file, outdir):
"""Fix the NPP VIIRS RDR/SDR files with respect to oribit number.
The
RDR/SDR file is read and the correct orbit number is inserted, and
the
filename is fixed as well."""
import shutil
# Determine the new output filename:
start_orbnum = orbits['start']
npp_filename = os.path.basename(npp_file)
new_filename = (npp_filename.split('_b')[0] +
'_b%.5d' % (start_orbnum) +
npp_filename[npp_filename.find('_c')::])
outfile = os.path.join(outdir, new_filename)
if os.path.exists(outfile):
print "File exists! %s" % os.path.basename(outfile)
return outfile
shutil.copy(npp_file, outfile)
# Start browsing file and change the orbit number:
out = h5py.File(outfile)
for group in out['/Data_Products'].keys():
for dset in out['/Data_Products'][group]:
# Attributes:
subsubg_attrs = out['/Data_Products'][group][dset].attrs
for key, val in subsubg_attrs.items():
if key in ['AggregateBeginningOrbitNumber',
'N_Beginning_Orbit_Number']:
start_orbnum = orbits[group+dset+'Beginning']
#print "Change orbit number from 1", start_orbnum
val = np.array([[start_orbnum]]).astype('uint64')
out['/Data_Products'][group][dset].attrs[key] =
val
if key in ['AggregateEndingOrbitNumber']:
end_orbnum = orbits[group+dset+'Ending']
#print "Change orbit number from 1", end_orbnum
val = np.array([[end_orbnum]]).astype('uint64')
out['/Data_Products'][group][dset].attrs[key] =
val
return outfile