test_class_KdNN.py 902 B

1234567891011121314151617181920212223
  1. #!/usr/bin/python
  2. import class_KdJamet as kdj
  3. import numpy as np
  4. import sys
  5. if len(sys.argv) != 4:
  6. print "test_class_KdNN.py must be launch with three arguments:"
  7. print " $ test_class_KdNN.py LOG_KdNeuralNetwork_TestCase_Input.csv your_output.csv idSensor[idMERIS, idSEAWIFS, idMODIS]"
  8. sys.exit(-1)
  9. # class KdJamet instance initialization for seleted sensor (argv[3])
  10. K = kdj.KdJamet(sys.argv[3])
  11. # test case Rrs file (argv[1]) reading (ie: LOG_KdNeuralNetwork_TestCase_Input.csv)
  12. tab = np.loadtxt(sys.argv[1], skiprows=1)
  13. # array to store Kd results
  14. KDs = np.zeros(tab.shape,dtype=np.float32)
  15. # for each line of input file compute the Kd for selected Sensor
  16. for i in range(tab.shape[0]):
  17. KDs[i,:] = K.compute_allKd(tab[i,:])
  18. # write result in argv[2] file
  19. np.savetxt(sys.argv[2],KDs,fmt='%.7f',header="Kd%d Kd%d Kd%d Kd%d Kd%d Kd%d" %(K.WL[0],K.WL[1],K.WL[2],K.WL[3],K.WL[4],K.WL[5]))