<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Calibration Data
Step1:  The object cdata now manages all the calibration images. The images are converted to arrays into a file called calibration.h5. A HDF5 file can be opened using the utility HDFview. Data is arranged in the following hierarchy
Step2:  To retrieve a specific calibration image, from the HDF5 file, as a numpy array
Step3:  To retrieve a group of datasets by specifying just the camera
Step4:  To iterate through the group use
Step5:  Particle Data
Step6:  The object cdata now manages all the particle images. The images are converted to arrays into a file called particle.h5. 
ParticleData object also behaves similarly as a CalibrationData object.
Note that the attributes are slightly different, hence the arguments for the function get_dset has slightly changed
<ASSISTANT_TASK:>
Python Code:
cd assignment/calibration_images/
cdata = CalibrationData()
cdata.config()
cdata.create_h5()
Explanation: Calibration Data
End of explanation
import json
print json.dumps(cdata.h5dict, indent=4) #Json used to print cdata.h5dict neatly
Explanation: The object cdata now manages all the calibration images. The images are converted to arrays into a file called calibration.h5. A HDF5 file can be opened using the utility HDFview. Data is arranged in the following hierarchy:
End of explanation
arr = cdata.get_dset(camera=0, z_loc=-6) #Note: It returns a numpy array, not a h5py dataset!
print arr
Explanation: To retrieve a specific calibration image, from the HDF5 file, as a numpy array:
End of explanation
grp = cdata.get_camera_grp(camera=0)
print grp
Explanation: To retrieve a group of datasets by specifying just the camera:
End of explanation
print 'Group attributes = ', grp.attrs.keys(), grp.attrs['cam']
for dset in grp.values():
    print dset
    print 'Dataset attributes = ', dset.attrs.keys(), dset.attrs['cam'], dset.attrs['z']
    arr = dset[...]
    print arr
Explanation: To iterate through the group use:
Note that the group and the datasets have attributes stored in them.
End of explanation
cd ../particle_images/
pdata = ParticleData()
pdata.config()
pdata.create_h5()
Explanation: Particle Data
End of explanation
arr = pdata.get_dset(camera=0, ab='a', time=47)
grp = pdata.get_camera_grp(camera=0)
Explanation: The object cdata now manages all the particle images. The images are converted to arrays into a file called particle.h5. 
ParticleData object also behaves similarly as a CalibrationData object.
Note that the attributes are slightly different, hence the arguments for the function get_dset has slightly changed
End of explanation
<END_TASK>