# Error in phase processing

**URL:** <https://openradar.discourse.group/t/error-in-phase-processing/329>\
**Category:** Corrections/Data Quality\
**Tags:** py-art\
**Created:** [October 14, 2023, 11:45am UTC](https://openradar.discourse.group/t/error-in-phase-processing/329 "2023-10-14T11:45:16Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jagdish\_jena](https://avatars.discourse-cdn.com/v4/letter/j/b19c9b/32.png) [@Jagdish\_jena](https://openradar.discourse.group/u/Jagdish_jena)\
**Post date:** [October 14, 2023, 11:45am UTC](https://openradar.discourse.group/t/error-in-phase-processing/329/1 "2023-10-14T11:45:16Z")

</div>

I am using a C band radar with radar fields [‘DBZ’, ‘PHIDP’, ‘RHOHV’, ‘VEL’, ‘WIDTH’, ‘ZDR’]  
for phase processing i was using this code  
phidp, kdp = pyart.correct.phase\_proc\_lp(radar, 0.0,refl\_field=‘DBZ’,phidp\_field=‘PHIDP’,rhv\_field=‘RHOHV’,ncp\_field=‘RHOHV’ ,LP\_solver = “cvxopt”,debug=True)  
error :  
Cell In[4], line 6  
1 # the next line force only the first sweep to be processed, this  
2 # significantly speeds up the calculation but should be commented out  
3 # in production so that the entire volume is processed  
4 radar.sweep\_start\_ray\_index[‘data’] = np.array([0])  
----\> 6 phidp, kdp = pyart.correct.phase\_proc\_lp(radar, 0.0,refl\_field=‘DBZ’,phidp\_field=‘PHIDP’,rhv\_field=‘RHOHV’,ncp\_field=‘RHOHV’ ,LP\_solver = “cvxopt”,debug=True)  
8 radar.add\_field(‘proc\_dp\_phase\_shift’, phidp)  
9 radar.add\_field(‘recalculated\_diff\_phase’, kdp)

File ~\anaconda3\Lib\site-packages\pyart\correct\phase\_proc.py:1196, in phase\_proc\_lp(radar, offset, debug, self\_const, low\_z, high\_z, min\_phidp, min\_ncp, min\_rhv, fzl, sys\_phase, overide\_sys\_phase, nowrap, really\_verbose, LP\_solver, refl\_field, ncp\_field, rhv\_field, phidp\_field, kdp\_field, unf\_field, window\_len, proc, coef)  
1192 mysoln = LP\_solver\_pyglpk(  
1193 A\_Matrix, B\_vectors, nw, really\_verbose=really\_verbose  
1194 )  
1195 elif LP\_solver == “cvxopt”:  
 → 1196 mysoln = LP\_solver\_cvxopt(A\_Matrix, B\_vectors, nw)  
1197 elif LP\_solver == “cylp”:  
1198 mysoln = LP\_solver\_cylp(  
1199 A\_Matrix, B\_vectors, nw, really\_verbose=really\_verbose  
1200 )

File ~\anaconda3\Lib\site-packages\pyart\correct\phase\_proc.py:720, in LP\_solver\_cvxopt(A\_Matrix, B\_vectors, weights, solver)  
718 this\_soln = np.zeros(n\_gates)  
719 for i in range(n\_gates):  
 → 720 this\_soln[i] = sol[“x”][i + n\_gates]  
722 # apply smoothing filter and record in output array  
723 mysoln[raynum, :] = smooth\_and\_trim(this\_soln, window\_len=5, window=“sg\_smooth”)

TypeError: ‘NoneType’ object is not subscriptable

if anyone has insights on how to solve this I would greatly appreciate your guidance

---

<div class="post-metadata">

**Author:** ![mgrover1](https://yyz2.discourse-cdn.com/free1/user_avatar/openradar.discourse.group/mgrover1/32/7_2.png) [@mgrover1](https://openradar.discourse.group/u/mgrover1)\
**Post date:** [October 17, 2023, 4:22pm UTC](https://openradar.discourse.group/t/error-in-phase-processing/329/2 "2023-10-17T16:22:48Z")

</div>

Could you run

```bash
conda list

```

and post the output so we can have an idea of what versions you have installed? Also, which data file is this?

---

<div class="post-metadata">

**Author:** ![Jagdish\_jena](https://avatars.discourse-cdn.com/v4/letter/j/b19c9b/32.png) [@Jagdish\_jena](https://openradar.discourse.group/u/Jagdish_jena)\
**Post date:** [October 17, 2023, 7:53pm UTC](https://openradar.discourse.group/t/error-in-phase-processing/329/3 "2023-10-17T19:53:01Z")

</div>

![conda list](https://global.discourse-cdn.com/free1/uploads/openradar/original/1X/02c22083b56097b9abeabdd2f71fa5cafbf47c94.jpeg)

data file is from Thumba DWR data which is processed by me . i have attched a sample file below.

> **[RCTLS\_13MAY2018\_135449\_L2B\_STD.nc](https://drive.google.com/file/d/185r7_AHQzav7W3iVXnXD-xsR0Ytfdi7N/view?usp=sharing)**
>
> Google Drive file.

---

<div class="post-metadata">

**Author:** ![mgrover1](https://yyz2.discourse-cdn.com/free1/user_avatar/openradar.discourse.group/mgrover1/32/7_2.png) [@mgrover1](https://openradar.discourse.group/u/mgrover1)\
**Post date:** [October 18, 2023, 1:41pm UTC](https://openradar.discourse.group/t/error-in-phase-processing/329/4 "2023-10-18T13:41:15Z")

</div>

Which version of Py-ART are you running? The screenshot cuts off in the b portion of the packages.

I tested this on the latest version Py-ART, and it ran successfully:

```python
import pyart

# Read in the radar data
radar = pyart.io.read("RCTLS_13MAY2018_135449_L2B_STD.nc")

# Apply the phase processing
phidp, kdp = pyart.correct.phase_proc_lp(radar,
                                         0.0,
                                         refl_field="DBZ",
                                         phidp_field="PHIDP",
                                         rhv_field="RHOHV",
                                         ncp_field="RHOHV",
                                         LP_solver = "cvxopt",
                                         debug=True)

Unfolding
/Users/mgrover/git_repos/pyart/pyart/correct/phase_proc.py:177: RuntimeWarning: invalid value encountered in divide
  return abs(signal) / _noise
Exec time: 2.717604875564575
Doing 0
GLPK Simplex Optimizer 5.0
Doing 1
6526 rows, 2612 columns, 13038 non-zeros
      0: obj = 0.000000000e+00 inf = 1.071e+04 (2606)
   6322: obj = 1.739944370e+05 inf = 7.283e-14 (0) 60
* 6500: obj = 1.722717219e+05 inf = 9.104e-15 (0) 2
OPTIMAL LP SOLUTION FOUND
GLPK Simplex Optimizer 5.0
5021 rows, 2010 columns, 10028 non-zeros
      0: obj = 0.000000000e+00 inf = 1.472e+04 (2004)
Perturbing LP to avoid stalling [3618]...
   4415: obj = 3.303218515e+03 inf = 1.965e-06 (0) 42
Removing LP perturbation [5042]...
* 5042: obj = 1.192051355e+03 inf = 1.315e-13 (0) 6
OPTIMAL LP SOLUTION FOUND
Doing 2
GLPK Simplex Optimizer 5.0
3251 rows, 1302 columns, 6488 non-zeros
Doing 0: obj = 0.000000000e+00 inf = 9.807e+03 (1296)
Perturbing LP to avoid stalling [1663]...
   2239: obj = 1.739060931e+03 inf = 2.646e-09 (0) 20
Removing LP perturbation [2684]...
* 2684: obj = 3.778228050e+02 inf = 1.972e-13 (0) 4
OPTIMAL LP SOLUTION FOUND
 3
GLPK Simplex Optimizer 5.0
2336 rows, 936 columns, 4658 non-zeros
Doing 4
      0: obj = 0.000000000e+00 inf = 6.854e+03 (930)
   1833: obj = 4.101107728e+02 inf = 7.105e-14 (0) 17
* 2050: obj = 2.530848447e+02 inf = 8.384e-13 (0) 2
OPTIMAL LP SOLUTION FOUND
GLPK Simplex Optimizer 5.0
1806 rows, 724 columns, 3598 non-zeros
      0: obj = 0.000000000e+00 inf = 5.127e+03 (718)
   1166: obj = 3.333312791e+02 inf = 0.000e+00 (0) 10
* 1341: obj = 1.760857907e+02 inf = 2.194e-13 (0) 1
OPTIMAL LP SOLUTION FOUND
Doing 5
GLPK Simplex Optimizer 5.0
1061 rows, 426 columns, 2108 non-zeros
Doing 6
      0: obj = 0.000000000e+00 inf = 2.693e+03 (420)
    740: obj = 1.975207042e+02 inf = 1.315e-13 (0) 6
* 817: obj = 1.008230690e+02 inf = 4.619e-14 (0) 1
OPTIMAL LP SOLUTION FOUND
GLPK Simplex Optimizer 5.0
831 rows, 334 columns, 1648 non-zeros
Doing 7
      0: obj = 0.000000000e+00 inf = 1.950e+03 (328)
    512: obj = 1.378641183e+02 inf = 5.329e-15 (0) 4
* 604: obj = 6.297361663e+01 inf = 5.151e-14 (0) 1
OPTIMAL LP SOLUTION FOUND
GLPK Simplex Optimizer 5.0
626 rows, 252 columns, 1238 non-zeros
Doing 8
      0: obj = 0.000000000e+00 inf = 1.351e+03 (246)
    377: obj = 1.071771379e+02 inf = 1.427e-14 (0) 3
* 429: obj = 5.187844123e+01 inf = 5.063e-14 (0)
OPTIMAL LP SOLUTION FOUND
GLPK Simplex Optimizer 5.0
501 rows, 202 columns, 988 non-zeros
Doing 9
      0: obj = 0.000000000e+00 inf = 9.900e+02 (196)
    309: obj = 8.190416547e+01 inf = 2.320e-14 (0) 2
* 355: obj = 4.393185547e+01 inf = 1.954e-14 (0) 1
OPTIMAL LP SOLUTION FOUND
Doing 10
GLPK Simplex Optimizer 5.0
421 rows, 170 columns, 828 non-zeros
      0: obj = 0.000000000e+00 inf = 7.649e+02 (164)
    234: obj = 7.688575510e+01 inf = 3.553e-15 (0) 1
* 274: obj = 4.094557344e+01 inf = 3.375e-14 (0) 1
OPTIMAL LP SOLUTION FOUND
GLPK Simplex Optimizer 5.0
361 rows, 146 columns, 708 non-zeros
      0: obj = 0.000000000e+00 inf = 6.059e+02 (140)
    203: obj = 7.842866003e+01 inf = 3.553e-15 (0) 1
* 243: obj = 3.780782667e+01 inf = 0.000e+00 (0) 1
OPTIMAL LP SOLUTION FOUND

```

---

<div class="post-metadata">

**Author:** ![mgrover1](https://yyz2.discourse-cdn.com/free1/user_avatar/openradar.discourse.group/mgrover1/32/7_2.png) [@mgrover1](https://openradar.discourse.group/u/mgrover1)\
**Post date:** [October 18, 2023, 1:59pm UTC](https://openradar.discourse.group/t/error-in-phase-processing/329/5 "2023-10-18T13:59:47Z")

</div>

@Jagdish_jena - this line is the culprit. What is the reasoning for this line?

radar.sweep\_start\_ray\_index[‘data’] = np.array([0])

This will corrupt the radar object, leading to mismatched array lengths.

---

<div class="post-metadata">

**Author:** ![mgrover1](https://yyz2.discourse-cdn.com/free1/user_avatar/openradar.discourse.group/mgrover1/32/7_2.png) [@mgrover1](https://openradar.discourse.group/u/mgrover1)\
**Post date:** [October 19, 2023, 8:22pm UTC](https://openradar.discourse.group/t/error-in-phase-processing/329/6 "2023-10-19T20:22:44Z")

</div>

@Jagdish_jena - did this solve the issue?

---

<div class="post-metadata">

**Author:** ![Jagdish\_jena](https://avatars.discourse-cdn.com/v4/letter/j/b19c9b/32.png) [@Jagdish\_jena](https://openradar.discourse.group/u/Jagdish_jena)\
**Post date:** [October 20, 2023, 10:37am UTC](https://openradar.discourse.group/t/error-in-phase-processing/329/7 "2023-10-20T10:37:35Z")

</div>

Actually the file i have sent you it is working . This file was taken from thumba radar and has clutter and some time and sweep parametre is missing .so i have processed it and convert it into a nc file . That processed file is not working using that code. I am sending you a sample . please check .

> **[RCTLS\_13MAY2018\_135449\_L2B\_STD (1).nc](https://drive.google.com/file/d/1aLqZ_N6NKlsfl3SaJmQap1ZXiVSSRV9b/view?usp=sharing)**
>
> Google Drive file.

---

<div class="post-metadata">

**Author:** ![Jagdish\_jena](https://avatars.discourse-cdn.com/v4/letter/j/b19c9b/32.png) [@Jagdish\_jena](https://openradar.discourse.group/u/Jagdish_jena)\
**Post date:** [October 20, 2023, 6:32pm UTC](https://openradar.discourse.group/t/error-in-phase-processing/329/8 "2023-10-20T18:32:22Z")

</div>

There is another problem i am facing i.e after processing through that code results value are coming very absurd . just check following figures

1. PHIDP (raw data )  
 ![PHIDP_RAW](https://global.discourse-cdn.com/free1/uploads/openradar/original/1X/4a7f62f2167d9f464d952203694e3b3662186160.jpeg)  
2.calculated PHIDP  
 ![processed PHIDP](https://global.discourse-cdn.com/free1/uploads/openradar/original/1X/218e0b4245fa4ca1cb25393bc6764cab69f7cc3d.jpeg)  
3.UNFOLDED PHIDP - zero  
4.KDP  
 ![calculated KDP](https://global.discourse-cdn.com/free1/uploads/openradar/original/1X/47726a1cc4e48af831c99d17fd093a654011c58a.jpeg)

i dont know what is the problem . it is the problem with data or methods . because i have tried everything pyart , wradlib, titan didn’t get any satisfied result.

---

<div class="post-metadata">

**Author:** ![Jagdish\_jena](https://avatars.discourse-cdn.com/v4/letter/j/b19c9b/32.png) [@Jagdish\_jena](https://openradar.discourse.group/u/Jagdish_jena)\
**Post date:** [October 28, 2023, 4:52pm UTC](https://openradar.discourse.group/t/error-in-phase-processing/329/9 "2023-10-28T16:52:44Z")

</div>

@mgrover1 have u checked above figures ?

---

<div class="post-metadata">

**Author:** ![mgrover1](https://yyz2.discourse-cdn.com/free1/user_avatar/openradar.discourse.group/mgrover1/32/7_2.png) [@mgrover1](https://openradar.discourse.group/u/mgrover1)\
**Post date:** [October 30, 2023, 3:45pm UTC](https://openradar.discourse.group/t/error-in-phase-processing/329/10 "2023-10-30T15:45:32Z")

</div>

I have not had a chance yet - plan to take a look this week.

---

<div class="post-metadata">

**Author:** ![mgrover1](https://yyz2.discourse-cdn.com/free1/user_avatar/openradar.discourse.group/mgrover1/32/7_2.png) [@mgrover1](https://openradar.discourse.group/u/mgrover1)\
**Post date:** [November 2, 2023, 1:18pm UTC](https://openradar.discourse.group/t/error-in-phase-processing/329/11 "2023-11-02T13:18:36Z")

</div>

I suspect this is related to the data quality - I tried with multiple methods and found the same results.
