euroargodev / BlueCloud

Working space for BlueCloud demontrator 3 - Lops Task
0 stars 1 forks source link

1 line string to describe a PCM #11

Closed gmaze closed 4 years ago

gmaze commented 4 years ago

Provide code that return a 1 line string to describee a PCM Useful in figure titles

gmaze commented 4 years ago

Here is the function:

def pcm1liner(this_pcm):
    prtval = lambda x: "%0.2f" % x    
    getrge = lambda x: [np.max(x), np.min(x)]
    prtrge = lambda x: "[%s:%s]" % (prtval(getrge(x)[0]), prtval(getrge(x)[1]))
    prtfeatures = lambda p: "{%s}" % ", ".join(["'%s':%s" % (k, prtrge(v)) for k, v in p.features.items()])
    return "PCM :: K:%i, F:%i%s, %s" % (this_pcm.K, 
                                        this_pcm.F, 
                                        prtfeatures(this_pcm), 
                                        this_pcm._props['with_classifier'].upper())

It returns something line:

"PCM :: K:8, F:2{'temperature':[0.00:-990.00], 'salinity':[0.00:-990.00]}, GMM"