ARM-DOE / pyart

The Python-ARM Radar Toolkit. A data model driven interactive toolkit for working with weather radar data.
https://arm-doe.github.io/pyart/
Other
513 stars 266 forks source link

Not be8ing able to write_grid_mdv properly #1546

Closed MohitDahliya closed 6 months ago

MohitDahliya commented 6 months ago

Description

I wanted to convert nc radr files into grid_mmdv files While the conversion did happen but the filed of reflectivity was not there in the newly created grid_mdv file, only a few fields were there. I was expecting that all the files in the grid file would come into the mdv file

What I Did

import numpy as np import pyart

radar = pyart.io.read('DLI190207055229-IMD-B.nc') radar.fields.keys() out >> dict_keys(['T', 'Z', 'V', 'W', 'ZDR', 'KDP', 'PHIDP', 'SQI', 'RHOHV', 'HCLASS'])

grid = pyart.map.grid_from_radars(radar, grid_shape=(41, 401, 401), grid_limits=((0000.0, 20000.0), (-200000.0, 200000.0), (-200000.0, 200000.0)), gridding_algo='map_gates_to_grid', copy_field_dtypes=True) grid.fields.keys() out >> dict_keys(['HCLASS', 'ZDR', 'W', 'SQI', 'PHIDP', 'RHOHV', 'T', 'Z', 'V', 'KDP', 'ROI'])

pyart.io.write_grid_mdv('output_grid.mdv', grid, mdv_field_names= None, field_write_order= None)

file = pyart.io.read_grid_mdv("output_grid.mdv")

file.fields.keys() out >> dict_keys(['differential_reflectivity', 'cross_correlation_ratio', 'differential_phase', 'specific_differential_phase'])

mgrover1 commented 6 months ago

@MohitDahliya - thanks for raising this issue, by default the mdv writer will only write the fields with mappings to mdv data

mdv_field_names (dict or None, optional) – Mapping between grid fields and MDV data type names. Field names mapped to None or with no mapping will be excluded from writing. If None, the same field names will be used.

https://arm-doe.github.io/pyart/API/generated/pyart.io.write_grid_mdv.html#pyart.io.write_grid_mdv

You would need to provide these mappings to write out the additional fields

MohitDahliya commented 6 months ago

How could I provide these mappings ?

MohitDahliya commented 6 months ago

I'm waiting for your response.

mgrover1 commented 6 months ago

@MohitDahliya Sorry for the delay - I did not work on this during the weekend, and was attending the solar eclipse yesterday. We will take a look at this this week.

MohitDahliya commented 6 months ago

Okay.. Appreciate your response..

zssherman commented 6 months ago

@MohitDahliya The field mapping is a dictionary, so you need to reference try to reference that SQI is normalized coherent power etc. Or when you read the grid try to set file_field_names = True so your using the fields in your dataset. The problem is the mapping here: https://github.com/ARM-DOE/pyart/blob/243e0c5269b59ffd3c68ee41174d7c452fbd2204/pyart/default_config.py#L1094 Does not match the fields you have in the raw dataset for mdv.

So you either need to provide a dictionary that says SQI: normalized_coherent_power as @mgrover1 stated, or try setting file_field_names = True to try to bypass trying to map nonmatching field names

mgrover1 commented 6 months ago

@MohitDahliya - did that solution @zssherman work for you?

mgrover1 commented 6 months ago

@MohitDahliya - we are following up here, did that solution work?

MohitDahliya commented 6 months ago

yes, it worked. I checked default_config.py and found that I needed to change the name of my reflectivity field from 'Z' to 'DBZ'. However, I think you people should change this fixed file name and instead focus on the long name of the field as not everyone would have the name of the reflectivity field as 'DBZ' in their radar file.

MohitDahliya commented 6 months ago

@mgrover1 I saw that you have also handled some issues related to CSU_Radartools. I am also facing some issues in running that code. Can you help me with that ?

mgrover1 commented 6 months ago

yes, it worked. I checked default_config.py and found that I needed to change the name of my reflectivity field from 'Z' to 'DBZ'. However, I think you people should change this fixed file name and instead focus on the long name of the field as not everyone would have the name of the reflectivity field as 'DBZ' in their radar file.

Pull requests are always welcome!

@mgrover1 I saw that you have also handled some issues related to CSU_Radartools. I am also facing some issues in running that code. Can you help me with that ?

I would suggest opening an issue on the repository describing your issue. I am on travel this week, and likely would not be able to take a look until next week. One of the other developers there should be able to help.