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

Allow xcube serve to use SNAP specific color maps #84

Closed
AliceBalfanz opened this issue Jun 14, 2019 · 6 comments
Closed

Allow xcube serve to use SNAP specific color maps #84

AliceBalfanz opened this issue Jun 14, 2019 · 6 comments
Assignees
Labels
important This is very important for the project urgent High external pressure to address this ASAP xcube gen This is related to data cube generation, CLI "xcube gen" xcube serve This is related to server component, CLI "xcube serve"

Comments

@AliceBalfanz
Copy link
Contributor

AliceBalfanz commented Jun 14, 2019

The user wants a non linear color display, to map specific values with a predefined color.
This could be solved through making xcube serve able to import SNAP specific color maps provided by the user.

@AliceBalfanz AliceBalfanz added urgent High external pressure to address this ASAP important This is very important for the project xcube serve This is related to server component, CLI "xcube serve" labels Jun 14, 2019
@AliceBalfanz
Copy link
Contributor Author

@forman
Should this be implemented by allowing the --styles parameter accept not only matplotlib colormap names, but also files containing the SNAP specific color mapping? Or rather pass the SNAP colorbar file as a new parameter within the xcube serve command? something like --snapcol:
xcube serve --config my_server_config.yml --snapcol snap_specific_color_file.cpd
or should the snap specific color mapping files be included within the source code?

@forman
Copy link
Member

forman commented Jun 19, 2019

Should this be implemented by allowing the --styles parameter accept not only matplotlib colormap names, but also files containing the SNAP specific color mapping?

Yes. But there should also be a parameter, e.g. color_map_file, in the configuration file.

Or rather pass the SNAP colorbar file as a new parameter within the xcube serve command? something like --snapcol

I don't like exposing SNAP-specifcs in the xcube interface. Better make it an implementation detail: If any color map filename has extension .cpd and has valid SNAP-XML format then we read and apply it. In the future we should support a more flexible format allowing color mappings as described here.

@forman forman added the xcube gen This is related to data cube generation, CLI "xcube gen" label Jun 23, 2019
@forman
Copy link
Member

forman commented Jun 23, 2019

@AliceBalfanz, here is a new idea how to implement this feature:

We make sure that variables use special color table attributes. These attributes are already written by the SNAP NetCDF Writer anyway. For clarification what is meant here, have a look at our xcube demo cube generated from SNAP-written NetCDFs:

>> import xarray as xr
>> ds = xr.open_dataset('xcube/webapi/res/demo/cube.nc')
>> ds.conc_chl
<xarray.DataArray 'conc_chl' (time: 5, lat: 1000, lon: 2000)>
[10000000 values with dtype=float64]
Coordinates:
  * lat      (lat) float64 52.5 52.5 52.49 52.49 52.49 ... 50.01 50.01 50.0 50.0
  * lon      (lon) float64 0.00125 0.00375 0.00625 0.00875 ... 4.994 4.996 4.999
  * time     (time) datetime64[ns] 2017-01-16T10:09:21.834255872 ... 2017-01-30T10:46:33.836892416
Attributes:
    long_name:                  Chlorophylll concentration
    units:                      mg m^-3
    valid_pixel_expression:     c2rcc_flags.Valid_PE
    color_table_sample_values:  [ 0.   0.5  1.   2.   3.   4.5 13.  25.  30. ...
    color_table_red_values:     [  0   0  51   0   0   0 255 255 215 150]
    color_table_green_values:   [  0   0 102 204 255 128 255  95   0   0]
    color_table_blue_values:    [128 255 255 255 255   0   0   0   0   0]

If those need be overwritten, this would be best implemented in the specific SNAP input processor provided in the class SnapNetcdfInputProcessor that will be used with xcube gen. The input processor can then read any special color table files and set the above attributes accordingly.

Then we would have to change xcube serve to interprete the color table attributes and use them as default when no other style is configured for a given variable.

@AliceBalfanz AliceBalfanz self-assigned this Jun 27, 2019
@AliceBalfanz AliceBalfanz reopened this Jul 23, 2019
@AliceBalfanz
Copy link
Contributor Author

AliceBalfanz commented Jul 23, 2019

Resolve in a more generic way

  • extend xcube dataset specs to also consider color mappings as variable attributes
  • allow xcube gen to configure color mappings written as variable attributes
  • allow xcube serve to overwrite or specify color mappings
  • let xcube serve exploit the color mappings given as variable attributes
  • let xcube gen and xcube serve read color mappings from configuration using same syntax
  • do not allow ValueRange from server config if a variable has specified colormap which already includes valid value ranges

Other issues

  • Address error handling
  • Revise CDP parsing code

@AliceBalfanz
Copy link
Contributor Author

@forman
Copy link
Member

forman commented Apr 5, 2022

Closed in favor of #661

@forman forman closed this as completed Apr 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
important This is very important for the project urgent High external pressure to address this ASAP xcube gen This is related to data cube generation, CLI "xcube gen" xcube serve This is related to server component, CLI "xcube serve"
Projects
None yet
Development

No branches or pull requests

2 participants