Opened 6 years ago

Closed 4 years ago

Last modified 2 years ago

#1842 closed defect (fixed)

Petascope_Support scaling on irregular axes in WCS/WCPS

Reported by: Bang Pham Huu Owned by: Bang Pham Huu
Priority: major Milestone: 11.0
Component: petascope Version: development
Keywords: Cc: Dimitar Misev, Vlad Merticariu
Complexity: Medium

Description

Currently, Petascope doesn't support scale down/up for irregular axes. Hence, coverage contains irregular axis cannot be encoded in netCDF (server killed) as because of redundant/lack of coefficients compared to the number of scaled grid pixels.

The scaling down on irregular axes should follow the same way in Rasql to match the coefficients with selected grid pixels.

The scaling up on irregular axes need to find a way to find the coefficients which don't exist from the scaling up grid pixels. The formula to get the missing coefficients on irregular axes will be the reversed of this formula: https://stats.stackexchange.com/questions/281162/scale-a-number-between-a-range/281164#281164

Change History (9)

comment:1 by Dimitar Misev, 6 years ago

@bbell can you point Bang to the correct r_MiterX source file that does the scaling in rasdaman?

comment:4 by Bang Pham Huu, 6 years ago

Cc: bbell removed
Milestone: 9.79.8

comment:5 by Bang Pham Huu, 6 years ago

NEW formula works for negative indices as well.

import math
def scaleFloor(slo, shi, tlo, thi):
  scaleFactor = (shi - slo + 1) / (thi - tlo + 1)
  for tn in range(tlo, thi + 1):
    print( math.floor((tn-tlo) * scaleFactor) + slo )


# it returns the same result with: rasql -q 'SELECT encode(scale(<[-10:20] -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20>, [-2:2]), "text/csv")' --out string
scaleFloor(-10, 20, -2, 2)


NOT WORK for negative indices

The formula to find the cell numbers in rasql for scaling down is:

  scaleRatio = (source.hi - source.lo + 1) / (dest.hi - dest.lo + 1)
  realIndex = 0
  intIndex = 0
  loop from 0 until intIndex < source.hi:
      realIndex += scaleRatio
      intIndex = int(realIndex)
// e.g: source = [0:11], dest = [0:6]
scaleRatio = (11 - 0 + 1) / (6 - 0 + 1) = 1.7142857142857142

>>> int(0)
0
>>> int(1.7142857142857142 * 1)
1
>>> int(1.7142857142857142 * 2)
3
>>> int(1.7142857142857142 * 3)
5
>>> int(1.7142857142857142 * 4)
6
>>> int(1.7142857142857142 * 5)
8
>>> int(1.7142857142857142 * 6)
10

Then, `0, 1, 3, 5, 6, 8, 10` are the numbers from `source`
which are used to contribute to `dest`.
Last edited 2 years ago by Bang Pham Huu (previous) (diff)

comment:6 by Bang Pham Huu, 5 years ago

Milestone: 9.810.0

comment:7 by Bang Pham Huu, 5 years ago

Milestone: 10.0Future

comment:8 by Dimitar Misev, 5 years ago

Milestone: Future11.0

comment:9 by Bang Pham Huu, 4 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.