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

grid.py step conflict #22

Closed
demanasta opened this issue Jun 28, 2018 · 7 comments
Closed

grid.py step conflict #22

demanasta opened this issue Jun 28, 2018 · 7 comments
Assignees
Labels
Milestone

Comments

@demanasta
Copy link
Contributor

Use of the next options,
-r=-20/50/28/75 --x-grid-step 2 --y-grid-step 2

If lat or lon is not multiple of step then return the next error:

Traceback (most recent call last):
  File "./../bin/StrainTensor.py", line 241, in <module>
    grd = pystrain.grid.Grid(lonmin, lonmax, args.x_grid_step, latmin, latmax, args.y_grid_step)
  File "build/bdist.linux-x86_64/egg/pystrain/grid.py", line 70, in __init__
AssertionError
@demanasta demanasta added the bug label Jun 28, 2018
@demanasta demanasta added this to the v1.0-beta* milestone Jun 28, 2018
@xanthospap
Copy link
Contributor

Same issue with Python 3.x.
Created branch issue22 for solving it

@xanthospap
Copy link
Contributor

Bug description:
(for now handle only positive ranges):
input: x_min=18.75, x_max=30.25, x_step=2
the Grid class, will divide the range, to see how many points on the axis, i.e.
xpts = (x_max-x_min)/x_step = 5.75!!
But we cannot have 5.75 points. We can either have 5 points in which case the range will actually be:
[18.75, 28.75] or 6 points in which case the range will be [18.75, 30.75].
What do we want to do?
Options for solving:

  1. Always leave the max limit out (round towards the previous integer). That is if the number of points is 5.75 or 5.15 or 5.95, make it 5
  2. Always take the max limit in (round towards the next integer). That is if the number of points is 5.75 or 5.15 or 5.95, make it 6
  3. Depend on number of points (round towards the nearest integer). That is if the number of points > 5.5 make it 6, else make them 5.
    We should not chose 2 probably, but 1 and 3 are equally ok.
    Μητς τι λες;;

@demanasta
Copy link
Contributor Author

As a first solution, I think is better to follow option 1 (leave the max limit out) so that the grid will not come out of the point area.. ee??

@xanthospap
Copy link
Contributor

OK.
Έκανα τη λύση που είπαμε, άρα πάντα στο grid: x_min + xpts * x_step <= x_max (και ομοίως για τα y), άρα πάντα το μαξ είναι αυστηρό (δεν το υπερβαίνουμε ποτέ). Από την άλλη, μπορεί να είμαστε έως και x_step πιο πρίν από αυτό (σε μία ακραία περίπτωση, μπορεί κανονικά η διαίρεση (x_max-x_min)/x_step να έβγαινε 5.999.... το οποίο θα γίνει 5 ακριβώς, οπότε θα είμαστε 0.999*x_step πρίν το x_max)
Έκανα τις αλλαγές σε ένα καινούριο branch το issue22. Κάνε pull, επιβεβαίωσε κι εσύ κανα δύο παραδείγματα και αν είναι κομπλέ κάνουμε merge και κλείνουμε το issue.

@demanasta
Copy link
Contributor Author

First run ...

Traceback (most recent call last):
  File ".\StrainTensor.py", line 257, in <module>
    print('[DEBUG] {:5d}/{:7d}'.format(node_nr+1, grd.xpts*grd.ypts), end="\r")
ValueError: Unknown format code 'd' for object of type 'float'

Αν το ξεπεράσουμε αυτό το Print κολλάει στο επόμενο :

Traceback (most recent call last):
  File "./../bin/StrainTensor.py", line 263, in <module>
    sstr.estimate()
  File "build/bdist.linux-x86_64/egg/pystrain/strain.py", line 774, in estimate
  File "/usr/lib/python2.7/dist-packages/numpy/linalg/linalg.py", line 1915, in lstsq
    0, work, -1, iwork, 0)
TypeError: a float is required

@xanthospap
Copy link
Contributor

Λοιπόν,
το πρώτο λάθος ήταν λόγω διαφοράς python2.x με python3.x στη συνάρτηση floor() --να το θυμόμαστε για το μέλλον· η μία επιστρεφει float η άλλη int--. Διορθώθηκε ώστε να δουλεύει και με τις δύο.
Το δεύτερο, είναι άσχετο. Είχα βάλει μια παράμετρο στη συνάρτηση numpy.linalg.lstsq() για να μη βγαίνει αυτό το FutureWarning (δε ξέρω αν βγαίνει και σε σενα, είναι απλά warning και όχι error). Στο δικό μου pc έπιασε αλλά σε εσένα δεν πιάνει οπότε κάτι παίζει με τις εκδόσεις πάλι (python ή scipy).
Το ξαναέβγαλα, να είναι όπως πρίν και θα ανοίξω ένα καινούριο issue ώστε να το λύσουμε κάποια στιγμή.
Για κάνε pull, test, merge κτλ...

@demanasta
Copy link
Contributor Author

το τεσταρα και φαίνεται κομπλε οπότε το κάνω merge στο dev-danast και κλείνω μετά το issue

@demanasta demanasta mentioned this issue Jun 28, 2018
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