Skip to main content
Question

Convert Polar Coords in NetCDF

  • February 22, 2018
  • 2 replies
  • 25 views

Hi, I am pretty new to FME and trying to get my head around the new NetCDF sSupport.

I have a NetCDF 4 file with two raster bands: MEAN_WIND (magnitude) and MEAN_WIND_DIR (radians). I need to convert this to two new raster bands U and V. I.e. a vector equivalent to the input bands.

The math is like this:

mean_uwave = Math.Cos( mean_wave_dir * 2 * Math.PI / 360.0 );

mean_vwave = Math.Sos( mean_wave_dir * 2 * Math.PI / 360.0 );

But how would I apply this calculation to NetCDF files?

Thanks.

Garth

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

2 replies

daveatsafe
Safer
Forum|alt.badge.img+20
  • Safer
  • February 22, 2018

As the IFC property sets are configured in other systems i do not have prior knowledge of the attributes to expose these for the writers. I need to be able to feature attribute cleanup so that i can expose these attribute collections without prior knowledge of the feature information.

I have successfully exposed the attributes from the collections as a feature attribute but these are still hidden from the writer. I am able to interrogate each feature and build a picture of those attributes in Python but cannot seem to expose these programmatically. 

 

def processFeature(feature):
    print("**Processing feature**")
    print(feature.getAttribute('ifc_property_set'))
    #ifcpropertieslist = feature.getAttribute('ifc_properties')
    print(feature.getAllAttributeNames())
    i=0
    attrNames=feature.getAllAttributeNames()
    elementCount = int(feature.getAttribute("_element_count"))
    print(elementCount)
    exposeAttrsNames={}
    for i in range(elementCount):
        attrname = "ifc_properties{"+str(i)+"}.name"
        #print(attrname)
        #print(feature.getAttribute(attrname))
        featAttrName = feature.getAttribute(attrname)
        
        exposeAttrsNames[featAttrName] = feature.getAttribute(featAttrName)
    print(exposeAttrsNames)
    pass

Excuse the disorganization its a work in progress

FMEIFCAttr 

 Any ideas would be apricated. 


  • Author
  • February 25, 2018

Hi @gtissington,

You can use the RasterExpressionEvaluator transformer to create the new bands and perform the calculations. For examples on how to use the transformer, please see this article.

OK. I can see how that is part of the solution.

 

 

Sadly, I guess I don't even understand my own data very well.

 

 

The problem is that actually 'mean_wave' and 'mean_wave_dir' are NetCDF variables. Each of these variables has 360 raster bands (each band is lat/lon indexed).

 

 

So, in the RasterExpressionEvaluator I need to process all bands for both variables

 

 

i.e.

 

for each band(A,B) in (mean_wave, mean_wave_dir)

 

u = A * @sin( B * 2 * PI * 360 )

 

v = A * @cos( B * 2 * PI * 360 )

 

 

 

I tried a raster band separator before the expression evaluator but it throws an error saying only one "A" dataset can be supplied

 

Any other suggested are very much appreciated.

 

Thanks in advance,

 

Garth