Hi Anders,
In order to test the problem I need to send the nc file but it is too large. Actually I have already re-run the py file and got a new nc file and added the spectrum without any problem. But here the problem is related to the vanishing or disappearing of objects in the nc file after trying to add optical spectrum. The interesting point is that the emerging nc file is sufficiently large without involving any object. Actually I have applied to the following script, keeping the default parameters in the optical spectrum:
nc_file="C:/Users/file.nc"
bulk_configuration = nlread(nc_file,BulkConfiguration,object_id='gID000')[0]
optical_spectrum = OpticalSpectrum(
configuration=bulk_configuration,
kpoints=MonkhorstPackGrid(11,11,11),
energies=numpy.linspace(0,5,101)*eV,
broadening=0.1*eV,
bands_below_fermi_level=4,
bands_above_fermi_level=4,
)
nlsave(nc_file, optical_spectrum)