Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lost attributes after running calculate_param() #401

Closed
adokter opened this issue Jul 17, 2020 · 3 comments
Closed

lost attributes after running calculate_param() #401

adokter opened this issue Jul 17, 2020 · 3 comments
Labels
Milestone

Comments

@adokter
Copy link
Owner

adokter commented Jul 17, 2020

If we add a scan parameter CELL as follows:

data(example_scan)
example_scan_cell <- calculate_param(example_scan,CELL=ifelse(DBZH>0,0,1))

certain function fail on this new scan parameter:

> project_as_ppi(example_scan_cell)
 Error in CRS(paste("+proj=aeqd +lat_0=", attributes(param)$geo$lat, " +lon_0=",  : 
  No spaces permitted in PROJ4 argument-value pairs: +proj=aeqd +lat_0= +lon_0= +units=m 

The reason is that the new parameter has missing attributes, in particular the geo attributes:

> attributes(example_scan_cell$params$CELL)
$dim
[1] 480 360

$param
[1] "CELL"

c.f. DBZH:

> attributes(example_scan_cell$params$DBZH)
$dim
[1] 480 360

$class
[1] "param"  "matrix"

$radar
[1] "SE50"

$datetime
[1] "2015-10-18 18:00:00 UTC"

$geo
$geo$lat
[1] 56.3675

$geo$lon
[1] 12.8517

$geo$height
[1] 209

$geo$elangle
[1] 0.5

$geo$rscale
[1] 500

$geo$ascale
[1] 1


$param
[1] "DBZH"
@adokter adokter added the bug label Jul 17, 2020
@adokter adokter added this to the 0.6.0 milestone Jul 17, 2020
@bart1
Copy link
Collaborator

bart1 commented Jul 17, 2020

I encountered the same problem recently, the problem is some R functions like logical operations strip all attributes. One option it to later set attributes again if they are lost. The problem is that the input data can be quite diverse so it it not directly clear what attributes should be placed. e.g. what to do if not all input params of a scan have the same attributes?

@adokter
Copy link
Owner Author

adokter commented Jul 23, 2020

@bart1 the dim, class, radar, datetime and geo attributes should always be the same (but indeed can differ in theory if people paste together their own class object). How about checking that these attributes are present at the end of calculate_param() and if they are missing copy them from the first quantity in the expression generating the new parameter?

bart1 pushed a commit that referenced this issue Jul 31, 2020
@bart1 bart1 mentioned this issue Jul 31, 2020
adokter added a commit that referenced this issue Aug 6, 2020
@adokter
Copy link
Owner Author

adokter commented Aug 6, 2020

fixed by #408

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants