Closed johanna-bernal closed 7 years ago
Hi Johanna
Not sure off the top of my head what could be causing the error message. Would you mind doing the following to help me track it down?
yatsm -v cache /home/ideam/yatsm/7_59/p007r059/p007r059.yaml 1 8
/home/ideam/yatsm/7_59/p007r059/images.csv
I'll can rule out any obvious problems with those two sources of information. If not, more information about the dataset -- ideally, the dataset itself if it's small enough to zip and transfer over FTP -- would be helpful. It would also rule out issues with the installation of YATSM or its dependencies if you were able to successfully run the program against one of the example datasets or if you were able to make sure the test suite passes on your computer.
Best, Chris
Whoops -- looking back, I forgot to add the verbose flag. I edited my original reply to be the correct, verbose command
Thanks for your answer Chris.
I ran what you suggested me (see below). In addition, I ran the cache with the example of the scene p013r030, and it worked. So I have been thinking that maybe could be my images, however, I have been working correctly with my images using TSTools. To prepare them for YATSM and TSTools, I stacked them using ENVI 4.7 and produced BSQ files. But looking in QGIS the metadata of my images I found that the description of the data is different of the example images because it remains calling each band as .tif (I am not sure if it could be affecting the process):
Descripción del conjunto de datos /home/ideam/yatsm/7_59/p007r059/landsat_stack/p007r059/subset/images/LE70070591999233EDC00/LE70070591999233EDC00_stack Band_1=Layer (Band 1:LE70070591999233EDC00_sr_band1.tif) Band_2=Layer (Band 1:LE70070591999233EDC00_sr_band2.tif) Band_3=Layer (Band 1:LE70070591999233EDC00_sr_band3.tif) Band_4=Layer (Band 1:LE70070591999233EDC00_sr_band4.tif) Band_5=Layer (Band 1:LE70070591999233EDC00_sr_band5.tif) Band_6=Layer (Band 1:LE70070591999233EDC00_sr_band7.tif) Band_7=Layer (Band 1:LE70070591999233EDC00_band61.tif) Band_8=Layer (Band 1:LE70070591999233EDC00_cfmask.tif)
(yatsm_venv)ideam@ideam-Precision-WorkStation-T7500:~$ **yatsm -v cache /home/ideam/yatsm/7_59/p007r059/p007r059.yaml 1 8**
/home/ideam/yatsm_venv/local/lib/python2.7/site-packages/matplotlib/font_manager.py:273: UserWarning: Matplotlib is building the font cache using fc-list. This may take a moment.
warnings.warn('Matplotlib is building the font cache using fc-list. This may take a moment.')
09:12:31:DEBUG:179:config_parser._find_pickle:Using prediction method "LassoCV" from config file (/home/ideam/yatsm/yatsm/regression/pickles/sklearn_LassoCV_n50.pkl)
09:12:31:DEBUG:179:config_parser._find_pickle:Using prediction method "RLM" from config file (/home/ideam/yatsm/yatsm/regression/pickles/rlm_maxiter10.pkl)
09:12:32:DEBUG:45:cache.cache:Responsible for lines: [ 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233
234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251
252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269
270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287
288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305
306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323
324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341
342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359
360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377
378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395
396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413
414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431
432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449
450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467
468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485
486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503
504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521
522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539
540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557
558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575
576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593
594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611
612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629
630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647
648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665
666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683
684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701
702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719
720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737
738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755
756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773
774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791
792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809
810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827
828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845
846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863
864 865 866 867]
09:12:32:DEBUG:52:cache.cache:Reading in data from disk using GDAL
09:12:32:DEBUG:72:cache.cache:Caching line 0 to /home/ideam/yatsm/7_59/p007r059/landsat_stack/p007r059/subset/cache/yatsm_r0_n123_b8.npy.npz
09:12:32:DEBUG:107:cache.cache:Reading in data from disk using GDAL
Traceback (most recent call last):
File "/home/ideam/yatsm_venv/bin/yatsm", line 9, in <module>
load_entry_point('yatsm==0.6.1', 'console_scripts', 'yatsm')()
File "/home/ideam/yatsm_venv/local/lib/python2.7/site-packages/click/core.py", line 716, in __call__
return self.main(*args, **kwargs)
File "/home/ideam/yatsm_venv/local/lib/python2.7/site-packages/click/core.py", line 696, in main
rv = self.invoke(ctx)
File "/home/ideam/yatsm_venv/local/lib/python2.7/site-packages/click/core.py", line 1060, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/ideam/yatsm_venv/local/lib/python2.7/site-packages/click/core.py", line 889, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/ideam/yatsm_venv/local/lib/python2.7/site-packages/click/core.py", line 534, in invoke
return callback(*args, **kwargs)
File "/home/ideam/yatsm_venv/local/lib/python2.7/site-packages/click/decorators.py", line 17, in new_func
return f(get_current_context(), *args, **kwargs)
File "/home/ideam/yatsm/yatsm/cli/cache.py", line 108, in cache
Y = io.gdal_reader.read_row(df['filename'], job_line)
File "/home/ideam/yatsm/yatsm/io/stack_line_readers.py", line 155, in read_row
return self._read_row(row)
File "/home/ideam/yatsm/yatsm/io/stack_line_readers.py", line 138, in _read_row
data[n_b, i, :] = band.ReadAsArray(0, row, self.n_col, 1)
TypeError: long() argument must be a string or a number, not 'NoneType'
Hi Johanna
Thanks for providing the additional information. Unfortunately I'm still at a loss for an explanation. What's really curious to me is that I've tried substituting None
into both the assignment (data[n_b, i, :]
) and the GDAL call (band.ReadAsArray(0, row, self.n_col, 1)
) and putting None
into any of the possible argument values never produces the error you've described.
The metadata you see in QGIS is probably okay -- I think it's just information that ENVI has added into the header of its file format to describe what it should show in its user interface. The bands aren't actually TIF files but ENVI keeps track of the names of the TIF files the bands came from.
I have three proposals for continuing to debug this issue:
yatsm
repository downloaded into your home folder as the TSTools VM does):
cd ~/yatsm
git fetch --all
git checkout johanna
pip install -e .
yatsm -v cache /home/ideam/yatsm/7_59/p007r059/p007r059.yaml 1 8
gdalinfo
tool to ensure that all of the images you're trying to use were stacked and output by ENVI in the same way. The script checks to make sure that all of the images have the same attributes, like the same number of rows/columns, upper left coordinates, number of bands, etc. If you want to go this route, download the script I've attached (debug_94.txt
) and run it as follows:
bash debug_94.txt /home/ideam/yatsm/7_59/p007r059/landsat_stack/p007r059/subset/images > debug_94.log
> debug_94.log
bit of the command will "redirect" the output of the script into a text file instead of showing it in your terminal. When the script completes, you should have a new file, debug_94.log
, that holds the results. Upload this in a reply to this ticketSorry for the trouble -- wish I had a better way of debugging remotely! If this doesn't work I'll be out of ideas, but I hope we can get you and IDEAM up and running somehow.
@parevalo sorry (or, not sorry?) to drag you in, but you were just at IDEAM and might have some knowledge I don't. Would you mind reading through this thread and comment if you have any other ideas?
Not sorry at all! I don't have any other ideas to be honest, but I think the obvious next step is to run your debug script and inspect the results to see if we can find something. What's really strange is that I actually saw TS Tools working there normally, so I assume the images must have been fine, but I never really looked at them individually, or their metadata. However, I wonder if it has something to do with not specifying a "reference" output extent when creating the stacks, and then ENVI putting some strange value in those areas, that do not match the "NoData" flag in the metadata.
Thank you Chris!
I am goning to run the debug and then if it does not work I will share with you the images.
You have been very kind giving me your help.
Hello Chris:
I ran the debug (see attach) and with the results I think that the problem is with the extent of the images, because they did not have the same size or the same starting point. So, I am going to follow your scripts of pre-processing in order to be sure that the images have the same characteristics. What do you think?
Thanks for your kind help.
Hi Johanna
Having the extents consistent across the imagery is unfortunately a requirement so far in this version, so it will be progress to alter the extents of your images to match. I'm not exactly sure this will solve the problem that you're encountering, but it's progress in the right direction.
You should be able to just use gdal_translate
with the -projwin ulx uly lrx lry
argument to fix all of the extents to the same coordinates. It might be easiest to simply pick the coordinates to "stack" from the first image in the series.
Might be something like,
# Borrowed from https://github.com/dwtkns/gdal-cheat-sheet
function gdal_extent() {
if [ -z "$1" ]; then
echo "Missing arguments. Syntax:"
echo " gdal_extent <input_raster>"
return
fi
EXTENT=$(gdalinfo $1 |\
grep "Upper Left\|Lower Right" |\
sed "s/Upper Left //g;s/Lower Right //g;s/).*//g" |\
tr "\n" " " |\
sed 's/ *$//g' |\
tr -d "[(,]")
echo -n "$EXTENT"
}
# GDAL output format and format creation options -- change as you will
OUT_FORMAT=ENVI
OUT_OPTION="INTERLEAVE=BIP"
# Initialize the output extent as an empty string so we can define it with first image in loop
extent=""
# This find command assumes you're in the root directory of the imagery
for img in $(find ./ -name 'L*stack'); do
# If extent is empty, initialize
if [ "$extent" == "" ]; then
extent=$(gdal_extent $img)
echo "Stacking to extent: $extent"
fi
# Define some output name for the corrected images
out_name=${img}_fixed
gdal_translate -projwin $extent -of $OUT_FORMAT -co $OUT_OPTION $img $out_name
done
You might get some warnings from GDAL that, Computed -srcwin ... falls partially outside raster extent.
. These should be safe to ignore and are to be expected.
I wrote about snippets of code like this a few years ago in the 5th chapter in landsat_preprocess. That tutorial is very out of date, but it might be worth looking at. Please ask any questions you might have in this next step in this thread, however.
Cheers Chris
The script for adjusting the extent of the stacks worked! Now I have the cache files and I will continue with the other functions of the YATSM code. Thank you Chris.
Great to hear!
On Mon, Sep 12, 2016 at 5:15 PM, johanna-bernal notifications@github.com wrote:
The script for adjusting the extent of the stacks worked! Now I have the cache files and I will continue with the other functions of the YATSM code. Thank you Chris.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ceholden/yatsm/issues/94#issuecomment-246495984, or mute the thread https://github.com/notifications/unsubscribe-auth/AIrAxySwe2NcPJr6w7GM2rqGuzFubsYSks5qpcDVgaJpZM4Jl1rw .
@johanna-bernal Hooray!
I should have mentioned earlier, but running yatsm cache
before yatsm line
isn't strictly a requirement. The yatsm line
command will actually cache the time series data when it reads in for the first time, but having the data already cached will speed up reading in the data. yatsm cache
is mostly useful if you want to update the cached data when you add new observations or remove any existing observations (if, for instance, you found that the image was very misregistered or the image was filled with clouds the cloud mask missed).
The two commands end up running the same code that was causing the trouble so we've fixed the issue for both commands :)
When I run the cache function in the terminal of Ubuntu I get this error: TypeError: long() argument must be a string or a number, not 'NoneType'. I do not know how to fix it. I have tried different options like change the job number the total jobs, the locations and directories where I have the .csv, the input images (Landsat 7. Envi BSQ), the folder of the output and also the parameter called prediction. But it has not worked. Thanks in advance for your help
p007r059yaml.txt
(yatsm_venv)ideam@ideam-Precision-WorkStation-T7500:~$ yatsm cache /home/ideam/yatsm/7_59/p007r059/p007r059.yaml 1 8 /home/ideam/yatsm_venv/local/lib/python2.7/site-packages/matplotlib/font_manager.py:273: UserWarning: Matplotlib is building the font cache using fc-list. This may take a moment. warnings.warn('Matplotlib is building the font cache using fc-list. This may take a moment.') Traceback (most recent call last): File "/home/ideam/yatsm_venv/bin/yatsm", line 9, in
load_entry_point('yatsm==0.6.1', 'console_scripts', 'yatsm')()
File "/home/ideam/yatsm_venv/local/lib/python2.7/site-packages/click/core.py", line 716, in call
return self.main(_args, _kwargs)
File "/home/ideam/yatsm_venv/local/lib/python2.7/site-packages/click/core.py", line 696, in main
rv = self.invoke(ctx)
File "/home/ideam/yatsm_venv/local/lib/python2.7/site-packages/click/core.py", line 1060, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/ideam/yatsm_venv/local/lib/python2.7/site-packages/click/core.py", line 889, in invoke
return ctx.invoke(self.callback, _ctx.params)
File "/home/ideam/yatsm_venv/local/lib/python2.7/site-packages/click/core.py", line 534, in invoke
return callback(_args, _kwargs)
File "/home/ideam/yatsm_venv/local/lib/python2.7/site-packages/click/decorators.py", line 17, in new_func
return f(get_current_context(), args, *_kwargs)
File "/home/ideam/yatsm/yatsm/cli/cache.py", line 108, in cache
Y = io.gdal_reader.read_row(df['filename'], job_line)
File "/home/ideam/yatsm/yatsm/io/stack_line_readers.py", line 155, in read_row
return self._read_row(row)
File "/home/ideam/yatsm/yatsm/io/stack_line_readers.py", line 138, in _read_row
data[n_b, i, :] = band.ReadAsArray(0, row, self.n_col, 1)
TypeError: long() argument must be a string or a number, not 'NoneType'