Saving PyDDA Output Grids to NetCDF Files and Using Output Grids in another Script

Hey, y’all! I’m currently working on a Dual-Doppler Analysis for my Master’s thesis, and I’m using PyDDA since previous students in my research group have used it. However, because I want to play around with plotting the data after running the “pydda.retrieval.get_dd_wind_field” function in my script, I want to save the derived wind fields as NetCDF files - one file for each radar grid. After all, waiting 10-30 minutes for the retrieval function to run doesn’t really do any good when I’m simply working on plotting the data. I know I can use the Spyder console to adjust plotting parameters, but that only works if I’m doing everything in the same session. If I have to come back to plotting the next day, I have to re-run my script (and therefore wait 10-30 minutes for the retrieval function to run) to get the DDA grids again. Needless to say, it’s not efficient.

Now, while I did notice that someone asked about saving PyDDA output grids to NetCDF files last year, I have some follow-up questions/issues because even though I think I’m saving the output grids correctly, I can’t seem to get PyDDA to read-in the output files…however, Py-ART does seem to read-in the grids correctly. Is this supposed to happen? If so, how does plotting the data work if PyDDA isn’t reading in the grids?

I should also note that when I first tried saving the PyDDA grids to NetCDF files, I got a ValueError: “failed to prevent overwriting existing key units in attrs on variable ‘time’. This is probably an encoding field used by xarray to describe how a variable is serialized.” A quick Google Search seemed to indicate that the attribute needed to be removed, so could that have somehow messed up saving the PyDDA output grids?

If it helps, the code where I attempt to separate the list of retrieved wind fields and write-out the radars’ corresponding grids is below:

5) Separate DD Grids into Radar Grids:

DD_Grid1 = DD_Grids[0]
DD_Grid2 = DD_Grids[1]
print(“DD Grids separated into Radar Grids…Writing-out Xarray Datasets as NetCDF Files.”)

6) Write-Out Xarray Datasets as NetCDF Files:

radar1_output_file = “DDA_Att1Result_Radar1.nc”
radar2_output_file = “DDA_Att1Result_Radar2.nc”
radar1_output_path = data_directory+radar1_output_file
radar2_output_path = data_directory+radar2_output_file
DD_Grid1[“time”].attrs.pop(“units”)
DD_Grid2[“time”].attrs.pop(“units”)
DD_Grid1.to_netcdf(radar1_output_path)
DD_Grid2.to_netcdf(radar2_output_path)
print(“Xarray Datasets successfully written-out as NetCDF Files…Ending Script.”)
If anyone has any advice/ideas, I’m am all ears!