janus-llm 4.3.1__py3-none-any.whl → 4.4.5__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (136) hide show
  1. janus/__init__.py +1 -1
  2. janus/__main__.py +1 -1
  3. janus/_tests/evaluator_tests/EvalReadMe.md +85 -0
  4. janus/_tests/evaluator_tests/incose_tests/incose_large_test.json +39 -0
  5. janus/_tests/evaluator_tests/incose_tests/incose_small_test.json +17 -0
  6. janus/_tests/evaluator_tests/inline_comment_tests/mumps_inline_comment_test.m +71 -0
  7. janus/_tests/test_cli.py +3 -2
  8. janus/cli/aggregate.py +135 -0
  9. janus/cli/cli.py +117 -0
  10. janus/cli/constants.py +49 -0
  11. janus/cli/database.py +289 -0
  12. janus/cli/diagram.py +207 -0
  13. janus/cli/document.py +183 -0
  14. janus/cli/embedding.py +122 -0
  15. janus/cli/llm.py +191 -0
  16. janus/cli/partition.py +134 -0
  17. janus/cli/pipeline.py +123 -0
  18. janus/cli/self_eval.py +147 -0
  19. janus/cli/translate.py +192 -0
  20. janus/converter/__init__.py +1 -1
  21. janus/converter/_tests/test_translate.py +7 -5
  22. janus/converter/chain.py +180 -0
  23. janus/converter/converter.py +444 -153
  24. janus/converter/diagram.py +8 -6
  25. janus/converter/document.py +27 -16
  26. janus/converter/evaluate.py +143 -144
  27. janus/converter/partition.py +2 -10
  28. janus/converter/requirements.py +4 -40
  29. janus/converter/translate.py +3 -59
  30. janus/embedding/collections.py +1 -1
  31. janus/language/alc/_tests/alc.asm +3779 -0
  32. janus/language/binary/_tests/hello.bin +0 -0
  33. janus/language/block.py +78 -14
  34. janus/language/file.py +1 -1
  35. janus/language/mumps/_tests/mumps.m +235 -0
  36. janus/language/treesitter/_tests/languages/fortran.f90 +416 -0
  37. janus/language/treesitter/_tests/languages/ibmhlasm.asm +16 -0
  38. janus/language/treesitter/_tests/languages/matlab.m +225 -0
  39. janus/llm/models_info.py +9 -1
  40. janus/metrics/_tests/asm_test_file.asm +10 -0
  41. janus/metrics/_tests/mumps_test_file.m +6 -0
  42. janus/metrics/_tests/test_treesitter_metrics.py +1 -1
  43. janus/metrics/metric.py +47 -124
  44. janus/metrics/prompts/clarity.txt +8 -0
  45. janus/metrics/prompts/completeness.txt +16 -0
  46. janus/metrics/prompts/faithfulness.txt +10 -0
  47. janus/metrics/prompts/hallucination.txt +16 -0
  48. janus/metrics/prompts/quality.txt +8 -0
  49. janus/metrics/prompts/readability.txt +16 -0
  50. janus/metrics/prompts/usefulness.txt +16 -0
  51. janus/parsers/code_parser.py +4 -4
  52. janus/parsers/doc_parser.py +12 -9
  53. janus/parsers/parser.py +7 -0
  54. janus/parsers/partition_parser.py +6 -4
  55. janus/parsers/reqs_parser.py +11 -8
  56. janus/parsers/uml.py +5 -4
  57. janus/prompts/prompt.py +2 -2
  58. janus/prompts/templates/README.md +30 -0
  59. janus/prompts/templates/basic_aggregation/human.txt +6 -0
  60. janus/prompts/templates/basic_aggregation/system.txt +1 -0
  61. janus/prompts/templates/basic_refinement/human.txt +14 -0
  62. janus/prompts/templates/basic_refinement/system.txt +1 -0
  63. janus/prompts/templates/diagram/human.txt +9 -0
  64. janus/prompts/templates/diagram/system.txt +1 -0
  65. janus/prompts/templates/diagram_with_documentation/human.txt +15 -0
  66. janus/prompts/templates/diagram_with_documentation/system.txt +1 -0
  67. janus/prompts/templates/document/human.txt +10 -0
  68. janus/prompts/templates/document/system.txt +1 -0
  69. janus/prompts/templates/document_cloze/human.txt +11 -0
  70. janus/prompts/templates/document_cloze/system.txt +1 -0
  71. janus/prompts/templates/document_cloze/variables.json +4 -0
  72. janus/prompts/templates/document_cloze/variables_asm.json +4 -0
  73. janus/prompts/templates/document_inline/human.txt +13 -0
  74. janus/prompts/templates/eval_prompts/incose/human.txt +32 -0
  75. janus/prompts/templates/eval_prompts/incose/system.txt +1 -0
  76. janus/prompts/templates/eval_prompts/incose/variables.json +3 -0
  77. janus/prompts/templates/eval_prompts/inline_comments/human.txt +49 -0
  78. janus/prompts/templates/eval_prompts/inline_comments/system.txt +1 -0
  79. janus/prompts/templates/eval_prompts/inline_comments/variables.json +3 -0
  80. janus/prompts/templates/micromanaged_mumps_v1.0/human.txt +23 -0
  81. janus/prompts/templates/micromanaged_mumps_v1.0/system.txt +3 -0
  82. janus/prompts/templates/micromanaged_mumps_v2.0/human.txt +28 -0
  83. janus/prompts/templates/micromanaged_mumps_v2.0/system.txt +3 -0
  84. janus/prompts/templates/micromanaged_mumps_v2.1/human.txt +29 -0
  85. janus/prompts/templates/micromanaged_mumps_v2.1/system.txt +3 -0
  86. janus/prompts/templates/multidocument/human.txt +15 -0
  87. janus/prompts/templates/multidocument/system.txt +1 -0
  88. janus/prompts/templates/partition/human.txt +22 -0
  89. janus/prompts/templates/partition/system.txt +1 -0
  90. janus/prompts/templates/partition/variables.json +4 -0
  91. janus/prompts/templates/pseudocode/human.txt +7 -0
  92. janus/prompts/templates/pseudocode/system.txt +7 -0
  93. janus/prompts/templates/refinement/fix_exceptions/human.txt +19 -0
  94. janus/prompts/templates/refinement/fix_exceptions/system.txt +1 -0
  95. janus/prompts/templates/refinement/format/code_format/human.txt +12 -0
  96. janus/prompts/templates/refinement/format/code_format/system.txt +1 -0
  97. janus/prompts/templates/refinement/format/requirements_format/human.txt +14 -0
  98. janus/prompts/templates/refinement/format/requirements_format/system.txt +1 -0
  99. janus/prompts/templates/refinement/hallucination/human.txt +13 -0
  100. janus/prompts/templates/refinement/hallucination/system.txt +1 -0
  101. janus/prompts/templates/refinement/reflection/human.txt +15 -0
  102. janus/prompts/templates/refinement/reflection/incose/human.txt +26 -0
  103. janus/prompts/templates/refinement/reflection/incose/system.txt +1 -0
  104. janus/prompts/templates/refinement/reflection/incose_deduplicate/human.txt +16 -0
  105. janus/prompts/templates/refinement/reflection/incose_deduplicate/system.txt +1 -0
  106. janus/prompts/templates/refinement/reflection/system.txt +1 -0
  107. janus/prompts/templates/refinement/revision/human.txt +16 -0
  108. janus/prompts/templates/refinement/revision/incose/human.txt +16 -0
  109. janus/prompts/templates/refinement/revision/incose/system.txt +1 -0
  110. janus/prompts/templates/refinement/revision/incose_deduplicate/human.txt +17 -0
  111. janus/prompts/templates/refinement/revision/incose_deduplicate/system.txt +1 -0
  112. janus/prompts/templates/refinement/revision/system.txt +1 -0
  113. janus/prompts/templates/refinement/uml/alc_fix_variables/human.txt +15 -0
  114. janus/prompts/templates/refinement/uml/alc_fix_variables/system.txt +2 -0
  115. janus/prompts/templates/refinement/uml/fix_connections/human.txt +15 -0
  116. janus/prompts/templates/refinement/uml/fix_connections/system.txt +2 -0
  117. janus/prompts/templates/requirements/human.txt +13 -0
  118. janus/prompts/templates/requirements/system.txt +2 -0
  119. janus/prompts/templates/retrieval/language_docs/human.txt +10 -0
  120. janus/prompts/templates/retrieval/language_docs/system.txt +1 -0
  121. janus/prompts/templates/simple/human.txt +16 -0
  122. janus/prompts/templates/simple/system.txt +3 -0
  123. janus/refiners/format.py +49 -0
  124. janus/refiners/refiner.py +113 -4
  125. janus/utils/enums.py +127 -112
  126. janus/utils/logger.py +2 -0
  127. {janus_llm-4.3.1.dist-info → janus_llm-4.4.5.dist-info}/METADATA +18 -18
  128. janus_llm-4.4.5.dist-info/RECORD +210 -0
  129. {janus_llm-4.3.1.dist-info → janus_llm-4.4.5.dist-info}/WHEEL +1 -1
  130. janus_llm-4.4.5.dist-info/entry_points.txt +3 -0
  131. janus/cli.py +0 -1488
  132. janus/metrics/_tests/test_llm.py +0 -90
  133. janus/metrics/llm_metrics.py +0 -202
  134. janus_llm-4.3.1.dist-info/RECORD +0 -115
  135. janus_llm-4.3.1.dist-info/entry_points.txt +0 -3
  136. {janus_llm-4.3.1.dist-info → janus_llm-4.4.5.dist-info}/LICENSE +0 -0
@@ -0,0 +1,416 @@
1
+ ! *****************************************************************************
2
+ MODULE ELMFIRE_IGNITION
3
+ ! *****************************************************************************
4
+
5
+ USE ELMFIRE_VARS
6
+ USE ELMFIRE_SUBS
7
+ USE MPI_F08
8
+ USE SORT
9
+
10
+ IMPLICIT NONE
11
+
12
+ REAL :: XLL, XSPAN, YLL, YSPAN, RCOUNT_SUM, RCOUNT_NOERC_SUM
13
+
14
+ CONTAINS
15
+
16
+ ! *****************************************************************************
17
+ SUBROUTINE DETERMINE_NUM_CASES_TOTAL
18
+ ! *****************************************************************************
19
+
20
+ INTEGER :: ICOL, IROW, IWX_BAND, I, I1, I2, FLOOR_NUM_ENSEMBLE_MEMBERS, IPYROME, N
21
+ INTEGER, PARAMETER :: NUM_CASES_TOTAL_MAX = 10000000
22
+ REAL :: X, Y, RCOUNT, RCOUNT_NOERC, RNUM_ENSEMBLE_MEMBERS, FRAC, R0
23
+
24
+ IF (.NOT. RANDOM_IGNITIONS) THEN
25
+ IF (MODE .NE. 2) THEN
26
+ IWX_BAND_STOP = IWX_BAND_START
27
+ ALLOCATE(NUM_CASES_PER_STARTING_WX_BAND(IWX_BAND_START:IWX_BAND_STOP))
28
+ NUM_CASES_PER_STARTING_WX_BAND(:) = NUM_ENSEMBLE_MEMBERS
29
+ NUM_CASES_TOTAL = NUM_ENSEMBLE_MEMBERS
30
+ NUM_STARTING_WX_BANDS = 1
31
+ ENDIF
32
+ ELSE
33
+ ALLOCATE(NUM_CASES_PER_STARTING_WX_BAND (IWX_BAND_START:IWX_BAND_STOP))
34
+ ALLOCATE(NUM_CASES_COMPLETE_PER_STARTING_WX_BAND (IWX_BAND_START:IWX_BAND_STOP))
35
+ ALLOCATE(HOURLY_OUTPUTS_FROM_STARTING_WX_BAND_DUMPED(IWX_BAND_START:IWX_BAND_STOP))
36
+
37
+ NUM_CASES_PER_STARTING_WX_BAND(:) = 0
38
+ NUM_CASES_COMPLETE_PER_STARTING_WX_BAND(:) = 0
39
+ HOURLY_OUTPUTS_FROM_STARTING_WX_BAND_DUMPED = .FALSE.
40
+
41
+ IF (USE_IGNITION_MASK) THEN
42
+ IXL_EDGEBUFFER = INT(EDGEBUFFER / IGN_MASK%CELLSIZE) + 1
43
+ IYL_EDGEBUFFER = INT(EDGEBUFFER / IGN_MASK%CELLSIZE) + 1
44
+ IXH_EDGEBUFFER = IGN_MASK%NCOLS - INT(EDGEBUFFER / IGN_MASK%CELLSIZE)
45
+ IYH_EDGEBUFFER = IGN_MASK%NROWS - INT(EDGEBUFFER / IGN_MASK%CELLSIZE)
46
+
47
+ DO IROW = 1, IGN_MASK%NROWS
48
+ IF (REAL(IROW ) * IGN_MASK%CELLSIZE .LT. EDGEBUFFER) IGN_MASK%R4(:,IROW,1) = ASP%NODATA_VALUE
49
+ IF (REAL(IGN_MASK%NROWS+1 - IROW ) * IGN_MASK%CELLSIZE .LT. EDGEBUFFER) IGN_MASK%R4(:,IROW,1) = ASP%NODATA_VALUE
50
+ ENDDO
51
+
52
+ DO ICOL = 1, IGN_MASK%NCOLS
53
+ IF (REAL(ICOL ) * IGN_MASK%CELLSIZE .LT. EDGEBUFFER) IGN_MASK%R4(ICOL,:,1) = ASP%NODATA_VALUE
54
+ IF (REAL(IGN_MASK%NCOLS+1 - ICOL ) * IGN_MASK%CELLSIZE .LT. EDGEBUFFER) IGN_MASK%R4(ICOL,:,1) = ASP%NODATA_VALUE
55
+ ENDDO
56
+
57
+ XSPAN = REAL(IGN_MASK%NCOLS) * IGN_MASK%CELLSIZE - 2.0 * EDGEBUFFER
58
+ YSPAN = REAL(IGN_MASK%NROWS) * IGN_MASK%CELLSIZE - 2.0 * EDGEBUFFER
59
+ XLL = IGN_MASK%XLLCORNER + EDGEBUFFER
60
+ YLL = IGN_MASK%YLLCORNER + EDGEBUFFER
61
+
62
+ ! Count up number of burnable pixels with nonzero ignition mask
63
+ N=0
64
+ DO IROW = IYL_EDGEBUFFER, IYH_EDGEBUFFER
65
+ DO ICOL = IXL_EDGEBUFFER, IXH_EDGEBUFFER
66
+ IF (IGN_MASK%R4(ICOL,IROW,1) .LT. IGN_MASK_CRIT ) CYCLE
67
+ IF (ISNONBURNABLE(ICOL,IROW) .AND. (.NOT. ALLOW_NONBURNABLE_PIXEL_IGNITION)) CYCLE
68
+ N = N + 1
69
+ ENDDO
70
+ ENDDO
71
+ NUM_IGNITABLE_PIXELS = N
72
+
73
+ ALLOCATE (N_ARR (1:NUM_IGNITABLE_PIXELS))
74
+ ALLOCATE (ICOL_ARR (1:NUM_IGNITABLE_PIXELS))
75
+ ALLOCATE (IROW_ARR (1:NUM_IGNITABLE_PIXELS))
76
+ ALLOCATE (IGN_MASK_ARR(1:NUM_IGNITABLE_PIXELS))
77
+ ALLOCATE (PROB (1:NUM_IGNITABLE_PIXELS+1))
78
+
79
+ N=0
80
+ DO IROW = IYL_EDGEBUFFER, IYH_EDGEBUFFER
81
+ DO ICOL = IXL_EDGEBUFFER, IXH_EDGEBUFFER
82
+ IF (IGN_MASK%R4(ICOL,IROW,1) .LT. IGN_MASK_CRIT) CYCLE
83
+ IF (ISNONBURNABLE(ICOL,IROW) .AND. (.NOT. ALLOW_NONBURNABLE_PIXEL_IGNITION)) CYCLE
84
+ N = N + 1
85
+ N_ARR(N) = N
86
+ ICOL_ARR(N) = ICOL
87
+ IROW_ARR(N) = IROW
88
+ ENDDO
89
+ ENDDO
90
+
91
+ ENDIF !USE_IGNITION_MASK
92
+
93
+ ALLOCATE (IWX_BAND_START_TEMP (1:NUM_CASES_TOTAL_MAX))
94
+ ALLOCATE (IWX_SERIAL_BAND_TEMP(1:NUM_CASES_TOTAL_MAX))
95
+
96
+ NUM_STARTING_WX_BANDS = 0
97
+ NUM_CASES_TOTAL = 0
98
+
99
+ IF (USE_ERC) THEN
100
+ ALLOCATE(IX_IGNFAC(1:IGN_MASK%NCOLS))
101
+ DO ICOL = 1, IGN_MASK%NCOLS
102
+ X = X_FROM_ICOL (ICOL, IGN_MASK%XLLCORNER, IGN_MASK%CELLSIZE)
103
+ IX_IGNFAC(ICOL) = MIN(MAX(ICOL_FROM_X (X, IGNFAC%XLLCORNER, IGNFAC%CELLSIZE),1),IGNFAC%NCOLS)
104
+ ENDDO
105
+
106
+ ALLOCATE(IY_IGNFAC(1:IGN_MASK%NROWS))
107
+ DO IROW = 1, IGN_MASK%NROWS
108
+ Y = Y_FROM_IROW (IROW, IGN_MASK%YLLCORNER, IGN_MASK%CELLSIZE)
109
+ IY_IGNFAC(IROW) = MIN(MAX(IROW_FROM_Y (Y, IGNFAC%YLLCORNER, IGNFAC%CELLSIZE),1),IGNFAC%NROWS)
110
+ ENDDO
111
+ ENDIF
112
+
113
+ RCOUNT_SUM = 0.
114
+ DO IWX_BAND = IWX_BAND_START, IWX_BAND_STOP, IWX_BAND_SKIP
115
+
116
+ NUM_STARTING_WX_BANDS = NUM_STARTING_WX_BANDS + 1
117
+
118
+ SELECT CASE (RANDOM_IGNITIONS_TYPE)
119
+
120
+ CASE(1)
121
+ RCOUNT = REAL(NUM_IGNITABLE_PIXELS)
122
+
123
+ CASE(2)
124
+
125
+ RCOUNT = 0.
126
+ IF (USE_ERC) THEN
127
+
128
+ IF (IWX_BAND .EQ. IWX_BAND_START) THEN
129
+ RCOUNT_NOERC = 0.0
130
+ DO I = 1, NUM_IGNITABLE_PIXELS
131
+ IROW = IROW_ARR(I)
132
+ ICOL = ICOL_ARR(I)
133
+ IF (USE_PYROMES .AND. CALIBRATION_CONSTANTS_BY_PYROME) THEN
134
+ IPYROME = MIN(MAX(PYROMES%I2(ICOL,IROW,1),1),128)
135
+ RCOUNT_NOERC = RCOUNT_NOERC + IGNITION_MASK_SCALE_FACTOR * IGNITION_DENSITY_ADJ_PYROME(IPYROME) * IGN_MASK%R4(ICOL,IROW,1)
136
+ ELSE
137
+ RCOUNT_NOERC = RCOUNT_NOERC + IGNITION_MASK_SCALE_FACTOR * IGN_MASK%R4(ICOL,IROW,1)
138
+ ENDIF
139
+ ENDDO
140
+ RCOUNT_NOERC_SUM = RCOUNT_NOERC
141
+ ELSE
142
+ RCOUNT_NOERC_SUM = RCOUNT_NOERC_SUM + RCOUNT_NOERC
143
+ ENDIF
144
+
145
+ DO I = 1, NUM_IGNITABLE_PIXELS
146
+ IROW = IROW_ARR(I)
147
+ ICOL = ICOL_ARR(I)
148
+ IF (USE_PYROMES .AND. CALIBRATION_CONSTANTS_BY_PYROME) THEN
149
+ IPYROME = MIN(MAX(PYROMES%I2(ICOL,IROW,1),1),128)
150
+ RCOUNT = RCOUNT + IGNITION_MASK_SCALE_FACTOR * IGNITION_DENSITY_ADJ_PYROME(IPYROME) * IGN_MASK%R4(ICOL,IROW,1) * IGNFAC%R4(IX_IGNFAC(ICOL),IY_IGNFAC(IROW),IWX_BAND)
151
+ ELSE
152
+ RCOUNT = RCOUNT + IGNITION_MASK_SCALE_FACTOR * IGN_MASK%R4(ICOL,IROW,1) * IGNFAC%R4(IX_IGNFAC(ICOL),IY_IGNFAC(IROW),IWX_BAND)
153
+ ENDIF
154
+ ENDDO
155
+ RCOUNT_SUM = RCOUNT_SUM + RCOUNT
156
+ ELSE
157
+ DO I = 1, NUM_IGNITABLE_PIXELS
158
+ IROW = IROW_ARR(I)
159
+ ICOL = ICOL_ARR(I)
160
+ IF (IGN_MASK%R4(ICOL,IROW,1) .GT. 0. ) THEN
161
+ IF (USE_PYROMES .AND. CALIBRATION_CONSTANTS_BY_PYROME) THEN
162
+ IPYROME = MIN(MAX(PYROMES%I2(ICOL,IROW,1),1),128)
163
+ RCOUNT = RCOUNT + IGNITION_MASK_SCALE_FACTOR * IGNITION_DENSITY_ADJ_PYROME(IPYROME) * IGN_MASK%R4(ICOL,IROW,1)
164
+ ELSE
165
+ RCOUNT = RCOUNT + IGNITION_MASK_SCALE_FACTOR * IGN_MASK%R4(ICOL,IROW,1)
166
+ ENDIF
167
+ ENDIF
168
+ ENDDO
169
+ ENDIF
170
+
171
+ CASE DEFAULT
172
+ WRITE(*,*) 'Error: Set RANDOM_IGNITIONS_TYPE to 1 or 2'
173
+ STOP
174
+
175
+ END SELECT
176
+
177
+ IF (NUM_ENSEMBLE_MEMBERS0 .LT. 0) THEN
178
+ RNUM_ENSEMBLE_MEMBERS = 0.01 * PERCENT_OF_PIXELS_TO_IGNITE * RCOUNT
179
+ FLOOR_NUM_ENSEMBLE_MEMBERS = FLOOR(RNUM_ENSEMBLE_MEMBERS)
180
+ FRAC = RNUM_ENSEMBLE_MEMBERS - REAL(FLOOR_NUM_ENSEMBLE_MEMBERS)
181
+ CALL RANDOM_NUMBER(R0)
182
+ IF (R0 .LE. FRAC) THEN
183
+ NUM_ENSEMBLE_MEMBERS = FLOOR_NUM_ENSEMBLE_MEMBERS + 1
184
+ ELSE
185
+ NUM_ENSEMBLE_MEMBERS = FLOOR_NUM_ENSEMBLE_MEMBERS
186
+ ENDIF
187
+ IF (NUM_ENSEMBLE_MEMBERS .NE. NUM_ENSEMBLE_MEMBERS) NUM_ENSEMBLE_MEMBERS = 0
188
+ ELSE
189
+ IF (NUM_ENSEMBLE_MEMBERS .GT. NINT(RCOUNT) .AND. (.NOT. ALLOW_MULTIPLE_IGNITIONS_AT_A_PIXEL) ) THEN
190
+ WRITE(*,100) 'Error: NUM_ENSEMBLE_MEMBERS is greater than the total number of ignitable pixels'
191
+ WRITE(*,100) 'Either reduce NUM_ENSEMBLE_MEMBERS, set ALLOW_MULTIPLE_IGNITIONS_AT_A_PIXEL = .TRUE.,'
192
+ WRITE(*,100) 'or set NUM_ENSEMBLE_MEMBERS < 0 and specify PERCENT_OF_PIXELS_TO_IGNITE.'
193
+ STOP
194
+ ENDIF
195
+ ENDIF
196
+
197
+ IF (NUM_ENSEMBLE_MEMBERS .GT. 0 ) THEN
198
+ NUM_CASES_PER_STARTING_WX_BAND(IWX_BAND) = NUM_ENSEMBLE_MEMBERS
199
+ I1 = NUM_CASES_TOTAL + 1
200
+ I2 = NUM_CASES_TOTAL + NUM_ENSEMBLE_MEMBERS
201
+ DO I = I1, I2
202
+ IWX_BAND_START_TEMP(I) = IWX_BAND
203
+ NUM_CASES_TOTAL = NUM_CASES_TOTAL + 1
204
+ IWX_SERIAL_BAND_TEMP(I) = NUM_STARTING_WX_BANDS
205
+ ENDDO
206
+ ENDIF
207
+
208
+ ENDDO ! IWX_BAND
209
+
210
+ ! IF (USE_ERC) DEALLOCATE(IX_IGNFAC, IY_IGNFAC)
211
+
212
+ ENDIF
213
+
214
+ IF (DUMP_CASES_TO_RUN_UP_FRONT) CALL WRITE_CASES_TO_RUN
215
+
216
+ 100 FORMAT(A)
217
+
218
+ ! *****************************************************************************
219
+ END SUBROUTINE DETERMINE_NUM_CASES_TOTAL
220
+ ! *****************************************************************************
221
+
222
+ ! *****************************************************************************
223
+ SUBROUTINE DETERMINE_IGNITION_LOCATIONS
224
+ ! *****************************************************************************
225
+
226
+ INTEGER :: I, ICASE, ICOL, IROW, IWX_BAND, ICASE_FOR_WX_BAND
227
+ REAL :: R0, IGN_MASK_SUM
228
+
229
+ STATS_IWX_BAND_START(:) = IWX_BAND_START_TEMP(1:NUM_CASES_TOTAL)
230
+ DEALLOCATE(IWX_BAND_START_TEMP)
231
+
232
+ STATS_IWX_SERIAL_BAND(:) = IWX_SERIAL_BAND_TEMP(1:NUM_CASES_TOTAL)
233
+ DEALLOCATE(IWX_SERIAL_BAND_TEMP)
234
+
235
+ ICASE = 0
236
+ IF (USE_ERC) THEN
237
+
238
+ DO IWX_BAND = IWX_BAND_START, IWX_BAND_STOP, IWX_BAND_SKIP
239
+
240
+ IF (NUM_CASES_PER_STARTING_WX_BAND(IWX_BAND) .LT. 1) CYCLE
241
+
242
+ IGN_MASK_SUM = 0.
243
+ DO I = 1, NUM_IGNITABLE_PIXELS
244
+ IROW = IROW_ARR(I)
245
+ ICOL = ICOL_ARR(I)
246
+ IGN_MASK_ARR(I) = IGN_MASK%R4(ICOL,IROW,1) * IGNFAC%R4(IX_IGNFAC(ICOL),IY_IGNFAC(IROW),IWX_BAND)
247
+ IGN_MASK_SUM = IGN_MASK_SUM + IGN_MASK_ARR(I)
248
+ ENDDO
249
+
250
+ IGN_MASK_ARR(:) = IGN_MASK_ARR(:) / IGN_MASK_SUM
251
+
252
+ ! N_ARR_R = REAL(N_ARR(:))
253
+ ! CALL DSORT(IGN_MASK_ARR(:), N_ARR_R(:), NUM_IGNITABLE_PIXELS, 2)
254
+
255
+ PROB(1) = 0.
256
+ DO I = 2, NUM_IGNITABLE_PIXELS
257
+ PROB(I) = PROB(I-1) + IGN_MASK_ARR(I-1)
258
+ ENDDO
259
+ PROB(NUM_IGNITABLE_PIXELS+1) = 1.
260
+
261
+ DO ICASE_FOR_WX_BAND = 1, NUM_CASES_PER_STARTING_WX_BAND(IWX_BAND)
262
+ ICASE = ICASE + 1
263
+
264
+ CALL RANDOM_NUMBER(R0)
265
+ CALL LOCATE(PROB(:), NUM_IGNITABLE_PIXELS+1, R0, I)
266
+ I = MIN(MAX(1,I),NUM_IGNITABLE_PIXELS)
267
+ STATS_X(ICASE) = X_FROM_ICOL (ICOL_ARR(I), IGN_MASK%XLLCORNER, IGN_MASK%CELLSIZE)
268
+ STATS_Y(ICASE) = Y_FROM_IROW (IROW_ARR(I), IGN_MASK%YLLCORNER, IGN_MASK%CELLSIZE)
269
+
270
+ IF (RANDOM_IGNITIONS_TYPE .EQ. 1) THEN
271
+ STATS_PROB(ICASE) = IGN_MASK%R4(ICOL_ARR(I),IROW_ARR(I),1)
272
+ ELSE
273
+ STATS_PROB(ICASE) = 1.
274
+ ENDIF
275
+
276
+ ENDDO
277
+ ENDDO
278
+
279
+ ELSE
280
+
281
+ IGN_MASK_SUM = 0.
282
+ DO I = 1, NUM_IGNITABLE_PIXELS
283
+ IROW = IROW_ARR(I)
284
+ ICOL = ICOL_ARR(I)
285
+ IGN_MASK_ARR(I) = IGN_MASK%R4(ICOL,IROW,1)
286
+ IGN_MASK_SUM = IGN_MASK_SUM + IGN_MASK_ARR(I)
287
+ ENDDO
288
+
289
+ IGN_MASK_ARR(:) = IGN_MASK_ARR(:) / IGN_MASK_SUM
290
+
291
+ ! N_ARR_R = REAL(N_ARR(:))
292
+ ! CALL DSORT(IGN_MASK_ARR(:), N_ARR_R(:), N, 2)
293
+
294
+ PROB(1) = 0.
295
+ DO I = 2, NUM_IGNITABLE_PIXELS
296
+ PROB(I) = PROB(I-1) + IGN_MASK_ARR(I-1)
297
+ ENDDO
298
+ PROB(NUM_IGNITABLE_PIXELS+1) = 1E0
299
+
300
+ DO ICASE = 1, NUM_CASES_TOTAL
301
+
302
+ CALL RANDOM_NUMBER(R0)
303
+ CALL LOCATE(PROB(:), NUM_IGNITABLE_PIXELS+1, R0, I)
304
+ I = MIN(MAX(1,I),NUM_IGNITABLE_PIXELS)
305
+ STATS_X(ICASE) = X_FROM_ICOL (ICOL_ARR(I), IGN_MASK%XLLCORNER, IGN_MASK%CELLSIZE)
306
+ STATS_Y(ICASE) = Y_FROM_IROW (IROW_ARR(I), IGN_MASK%YLLCORNER, IGN_MASK%CELLSIZE)
307
+
308
+ IF (RANDOM_IGNITIONS_TYPE .EQ. 1) THEN
309
+ STATS_PROB(ICASE) = IGN_MASK%R4(ICOL_ARR(I),IROW_ARR(I),1)
310
+ ELSE
311
+ STATS_PROB(ICASE) = 1.
312
+ ENDIF
313
+
314
+ ENDDO !ICASE = 1, NUM_CASES_TOTAL
315
+
316
+ ENDIF
317
+
318
+ DEALLOCATE(N_ARR, ICOL_ARR, IROW_ARR, IGN_MASK_ARR, PROB)
319
+ IF (USE_ERC) DEALLOCATE(IX_IGNFAC, IY_IGNFAC)
320
+
321
+ ! *****************************************************************************
322
+ END SUBROUTINE DETERMINE_IGNITION_LOCATIONS
323
+ ! *****************************************************************************
324
+
325
+ ! *****************************************************************************
326
+ SUBROUTINE WRITE_CASES_TO_RUN
327
+ ! *****************************************************************************
328
+
329
+ INTEGER :: IWX_BAND, IOS
330
+ CHARACTER(400) :: FN
331
+
332
+ FN = TRIM(OUTPUTS_DIRECTORY) // 'cases_to_run.csv'
333
+ OPEN(LUOUTPUT,FILE=TRIM(FN),FORM='FORMATTED',STATUS='REPLACE',IOSTAT=IOS)
334
+ WRITE(LUOUTPUT,9998) RCOUNT_SUM, RCOUNT_NOERC_SUM
335
+
336
+ WRITE(LUOUTPUT,'(A)') 'weather band,# cases'
337
+
338
+ DO IWX_BAND = IWX_BAND_START, IWX_BAND_STOP, IWX_BAND_SKIP
339
+ WRITE(LUOUTPUT,9999) IWX_BAND, NUM_CASES_PER_STARTING_WX_BAND(IWX_BAND)
340
+ ENDDO
341
+
342
+ CLOSE(LUOUTPUT)
343
+
344
+ 9998 FORMAT(F16.9, ',', F16.9)
345
+ 9999 FORMAT(I5,',',I4)
346
+
347
+ ! *****************************************************************************
348
+ END SUBROUTINE WRITE_CASES_TO_RUN
349
+ ! *****************************************************************************
350
+
351
+ ! *****************************************************************************
352
+ SUBROUTINE DETERMINE_NUM_CASES_TOTAL_CSV
353
+ ! *****************************************************************************
354
+
355
+ INTEGER :: I, IOS, N, IDUMMY, IWX_BAND
356
+ REAL :: RDUMMY
357
+ CHARACTER(400) :: FN
358
+
359
+ ALLOCATE(NUM_CASES_PER_STARTING_WX_BAND (IWX_BAND_START:IWX_BAND_STOP))
360
+ ALLOCATE(NUM_CASES_COMPLETE_PER_STARTING_WX_BAND (IWX_BAND_START:IWX_BAND_STOP))
361
+ ALLOCATE(HOURLY_OUTPUTS_FROM_STARTING_WX_BAND_DUMPED(IWX_BAND_START:IWX_BAND_STOP))
362
+
363
+ NUM_CASES_PER_STARTING_WX_BAND(:) = 0
364
+ NUM_CASES_COMPLETE_PER_STARTING_WX_BAND(:) = 0
365
+ HOURLY_OUTPUTS_FROM_STARTING_WX_BAND_DUMPED = .FALSE.
366
+
367
+ NUM_STARTING_WX_BANDS = 0
368
+ NUM_CASES_TOTAL = 0
369
+
370
+ FN=TRIM(FUELS_AND_TOPOGRAPHY_DIRECTORY) // '/' // TRIM(IGNITIONS_CSV_FILENAME)
371
+ OPEN(LUINPUT,FILE=TRIM(FN),FORM='FORMATTED',STATUS='OLD',IOSTAT=IOS)
372
+ IF (IOS .NE. 0) THEN
373
+ WRITE(*,*) 'Error: ', TRIM(FN), 'not found'
374
+ STOP
375
+ ENDIF
376
+
377
+ READ (LUINPUT,*,IOSTAT=IOS)
378
+ IF (IOS .NE. 0) THEN
379
+ WRITE(*,*) 'Error: bad header in', TRIM(FN)
380
+ STOP
381
+ ENDIF
382
+
383
+ N = 0
384
+ DO WHILE (IOS .EQ. 0)
385
+ READ(LUINPUT,*,IOSTAT=IOS) IDUMMY, IDUMMY, RDUMMY, RDUMMY
386
+ IF (IOS .EQ. 0) N = N + 1
387
+ ENDDO
388
+ CLOSE(LUINPUT)
389
+
390
+ ALLOCATE (CSV_ICASEARR(1:N))
391
+ ALLOCATE (CSV_IBANDARR(1:N))
392
+ ALLOCATE (CSV_XARR(1:N))
393
+ ALLOCATE (CSV_YARR(1:N))
394
+
395
+ OPEN(LUINPUT,FILE=TRIM(FN),FORM='FORMATTED',STATUS='OLD',IOSTAT=IOS)
396
+ READ (LUINPUT,*,IOSTAT=IOS)
397
+ DO I = 1, N
398
+ READ(LUINPUT,*,IOSTAT=IOS) CSV_ICASEARR(I), CSV_IBANDARR(I), CSV_XARR(I), CSV_YARR(I)
399
+ ENDDO
400
+ CLOSE(LUINPUT)
401
+ NUM_CASES_TOTAL=N
402
+
403
+ DO IWX_BAND = IWX_BAND_START, IWX_BAND_STOP, IWX_BAND_SKIP
404
+ NUM_STARTING_WX_BANDS = NUM_STARTING_WX_BANDS + 1
405
+ DO I = 1, NUM_CASES_TOTAL
406
+ IF (CSV_IBANDARR(I) .EQ. IWX_BAND) NUM_CASES_PER_STARTING_WX_BAND(IWX_BAND) = NUM_CASES_PER_STARTING_WX_BAND(IWX_BAND) + 1
407
+ ENDDO
408
+ ENDDO
409
+
410
+ ! *****************************************************************************
411
+ END SUBROUTINE DETERMINE_NUM_CASES_TOTAL_CSV
412
+ ! *****************************************************************************
413
+
414
+ ! *****************************************************************************
415
+ END MODULE ELMFIRE_IGNITION
416
+ ! *****************************************************************************
@@ -0,0 +1,16 @@
1
+ TITLE 'Hello, World! Program'
2
+ HELLO CSECT
3
+ STM 14,12,12(13)
4
+ LR 12,15
5
+ USING *,12
6
+ LA 15,SAVEAREA
7
+ ST 13,4(,15)
8
+ ST 15,8(13)
9
+ LR 13,15
10
+ WTO 'Hello, World!'
11
+ L 13,4(,13)
12
+ LM 14,12,12(13)
13
+ LA 15,0
14
+ BR 14
15
+ SAVEAREA DS 18F
16
+ END HELLO
@@ -0,0 +1,225 @@
1
+ %RobotArm Serial-link robot arm class
2
+ %
3
+ % A subclass of SerialLink than includes an interface to a physical robot.
4
+ %
5
+ % Methods::
6
+ %
7
+ % plot display graphical representation of robot
8
+ %-
9
+ % teach drive the physical and graphical robots
10
+ % mirror use the robot as a slave to drive graphics
11
+ %-
12
+ % jmove joint space motion of the physical robot
13
+ % cmove Cartesian space motion of the physical robot
14
+ %
15
+ % plus all other methods of SerialLink
16
+ %
17
+ % Properties::
18
+ %
19
+ % as per SerialLink class
20
+ %
21
+ % Note::
22
+ % - the interface to a physical robot, the machine, should be an abstract
23
+ % superclass but right now it isn't
24
+ % - RobotArm is a subclass of SerialLink.
25
+ % - RobotArm is a reference (handle subclass) object.
26
+ % - RobotArm objects can be used in vectors and arrays
27
+ %
28
+ % Reference::
29
+ % - http://www.petercorke.com/doc/robotarm.pdf
30
+ % - Robotics, Vision & Control, Chaps 7-9,
31
+ % P. Corke, Springer 2011.
32
+ % - Robot, Modeling & Control,
33
+ % M.Spong, S. Hutchinson & M. Vidyasagar, Wiley 2006.
34
+ %
35
+ % See also Machine, SerialLink, Link, DHFactor.
36
+
37
+
38
+ % Copyright (C) 1993-2017, by Peter I. Corke
39
+ %
40
+ % This file is part of The Robotics Toolbox for MATLAB (RTB).
41
+ %
42
+ % RTB is free software: you can redistribute it and/or modify
43
+ % it under the terms of the GNU Lesser General Public License as published by
44
+ % the Free Software Foundation, either version 3 of the License, or
45
+ % (at your option) any later version.
46
+ %
47
+ % RTB is distributed in the hope that it will be useful,
48
+ % but WITHOUT ANY WARRANTY; without even the implied warranty of
49
+ % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
50
+ % GNU Lesser General Public License for more details.
51
+ %
52
+ % You should have received a copy of the GNU Leser General Public License
53
+ % along with RTB. If not, see <http://www.gnu.org/licenses/>.
54
+ %
55
+ % http://www.petercorke.com
56
+
57
+ classdef RobotArm < SerialLink
58
+
59
+ properties
60
+ machine
61
+ ngripper
62
+ end
63
+
64
+ methods
65
+ function ra = RobotArm(robot, machine, varargin)
66
+ %RobotArm.RobotArm Construct a RobotArm object
67
+ %
68
+ % RA = RobotArm(L, M, OPTIONS) is a robot object defined by a vector of
69
+ % Link objects L with a physical robot interface M represented by an object
70
+ % of class Machine.
71
+ %
72
+ % Options::
73
+ %
74
+ % 'name', name set robot name property
75
+ % 'comment', comment set robot comment property
76
+ % 'manufacturer', manuf set robot manufacturer property
77
+ % 'base', base set base transformation matrix property
78
+ % 'tool', tool set tool transformation matrix property
79
+ % 'gravity', g set gravity vector property
80
+ % 'plotopt', po set plotting options property
81
+ %
82
+ % See also SerialLink.SerialLink, Arbotix.Arbotix.
83
+
84
+ ra = ra@SerialLink(robot, varargin{:});
85
+ ra.machine = machine;
86
+
87
+ ra.ngripper = machine.nservos - ra.n;
88
+ end
89
+
90
+ function delete(ra)
91
+ %RobotArm.delete Destroy the RobotArm object
92
+ %
93
+ % RA.delete() closes and destroys the machine interface object and the RobotArm
94
+ % object.
95
+
96
+ % attempt to destroy the machine interfaace
97
+ try
98
+ ra.machine.disconnect();
99
+ delete(ra.machine);
100
+ catch
101
+ end
102
+
103
+ % cleanup the parent object
104
+ delete@SerialLink(ra);
105
+ end
106
+
107
+ function jmove(ra, qf, t)
108
+ %RobotArm.jmove Joint space move
109
+ %
110
+ % RA.jmove(QD) moves the robot arm to the configuration specified by
111
+ % the joint angle vector QD (1xN).
112
+ %
113
+ % RA.jmove(QD, T) as above but the total move takes T seconds.
114
+ %
115
+ % Notes::
116
+ % - A joint-space trajectory is computed from the current configuration to QD.
117
+ %
118
+ % See also RobotArm.cmove, Arbotix.setpath.
119
+
120
+ if nargin < 3
121
+ t = 3;
122
+ end
123
+
124
+ q0 = ra.getq();
125
+ qt = jtraj(q0, qf, 20);
126
+
127
+ ra.machine.setpath(qt, t/20);
128
+ end
129
+
130
+ function cmove(ra, T, varargin)
131
+ %RobotArm.cmove Cartesian space move
132
+ %
133
+ % RA.cmove(T) moves the robot arm to the pose specified by
134
+ % the homogeneous transformation (4x4).
135
+ %
136
+ % Notes::
137
+ % - A joint-space trajectory is computed from the current configuration to
138
+ % QD using the jmove() method.
139
+ % - If the robot is 6-axis with a spherical wrist inverse kinematics are
140
+ % computed using ikine6s() otherwise numerically using ikine().
141
+ %
142
+ % See also RobotArm.jmove, Arbotix.setpath.
143
+ if ra.isspherical()
144
+ q = ra.ikine6s(T, varargin{:});
145
+ else
146
+ q = ra.ikine(T, ra.getq(), [1 1 1 1 0 0]);
147
+ end
148
+ ra.jmove(q);
149
+ end
150
+
151
+ function q = getq(ra)
152
+ %RobotArm.getq Get the robot joint angles
153
+ %
154
+ % Q = RA.getq() is a vector (1xN) of robot joint angles.
155
+ %
156
+ % Notes::
157
+ % - If the robot has a gripper, its value is not included in this vector.
158
+
159
+ q = ra.machine.getpos();
160
+ q = q(1:ra.n);
161
+ end
162
+
163
+ function mirror(ra)
164
+ %RobotArm.mirror Mirror the robot pose to graphics
165
+ %
166
+ % RA.mirror() places the robot arm in relaxed mode, and as it is moved by
167
+ % hand the graphical animation follows.
168
+ %
169
+ % See also SerialLink.teach, SerialLink.plot.
170
+
171
+ h = msgbox('The robot arm will go to relaxed mode, type q in the figure window to exit', ...
172
+ 'Mirror mode', 'warn');
173
+
174
+ ra.machine.relax();
175
+ while true
176
+ if get(gcf,'CurrentCharacter') == 'q'
177
+ break
178
+ end;
179
+
180
+ q = ra.machine.getpos();
181
+ ra.plot(q(1:ra.n));
182
+
183
+ end
184
+ ra.machine.relax([], false);
185
+
186
+ delete(h);
187
+ end
188
+
189
+ function teach(ra)
190
+ %RobotArm.teach Teach the robot
191
+ %
192
+ % RA.teach() invokes a simple GUI to allow joint space motion, as well
193
+ % as showing an animation of the robot on screen.
194
+ %
195
+ % See also SerialLink.teach, SerialLink.plot.
196
+
197
+ q0 = ra.machine.getpos();
198
+
199
+ teach@SerialLink(ra, 'q0', q0(1:ra.n), ...
200
+ 'callback', @(q) ra.machine.setpos([q q0(ra.n+1)]) );
201
+ end
202
+
203
+ function gripper(ra, open)
204
+ %RobotArm.gripper Control the robot gripper
205
+ %
206
+ % RA.gripper(C) sets the robot gripper according to C which is 0 for closed
207
+ % and 1 for open.
208
+ %
209
+ % Notes::
210
+ % - Not all robots have a gripper.
211
+ % - The gripper is assumed to be the last servo motor in the chain.
212
+ if open < 0 || open > 1
213
+ error('RTB:RobotArm:badarg', 'gripper control must be in range 0 to 1');
214
+ end
215
+
216
+ if ra.ngripper == 0
217
+ error('RTB:RobotArm:nofunc', 'robot has no gripper');
218
+ end
219
+
220
+ griplimits = ra.machine.gripper;
221
+ a = open*griplimits(1) + (1-open)*griplimits(2)
222
+ ra.machine.setpos(ra.n+1, a);
223
+ end
224
+ end
225
+ end