├── LICENSE
├── README.md
├── ass_res
├── CHN_adm_shp
│ └── CHN_adm_shp.txt
├── __init__.py
├── ass_singlesite_lsy.py
├── ass_singlesite_ws.py
├── ass_widearea_dis.py
├── ass_widearea_wsy.py
├── draw_geo_fig.py
├── init_nasa_solar.py
├── init_nasa_wind.py
├── sd_solar_data
│ └── sd_solar_data.txt
├── sd_temp_data
│ └── sd_temp_data.txt
└── sd_wind_data
│ └── sd_wind_data.txt
└── freq_a2c
├── README.md
├── c0122.out
└── dsusr.dll
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 | {one line to give the program's name and a brief idea of what it does.}
635 | Copyright (C) {year} {name of author}
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | {project} Copyright (C) {year} {fullname}
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # PowerXLab-Tools
2 | ## Simulation and Computing Toolkit for Power System with High Penetration of Renewable Energy Sources
3 | Maintainer: Yongji Cao yongji@sdu.edu.cn from Shandong University, China.
4 | ## Introduction
5 | ### QSAT V2.1
6 | Quantitative Synergy Assessment Toolkit for Renewable Energy Sources
7 | A software toolbox developed in Python for assessment and visualization of the spatiotemporal characteristics of
8 | regional renewable energy sources (wind and solar energy) to support preliminary regional planning.
9 | - Requirements
10 | PYTHON 2.7 (or higher)
11 | NUMPY (PYTHON package)
12 | MATPLOTLIB (PYTHON package)
13 | BASEMAP (PYTHON package)
14 | SCIPY (PYTHON package)
15 | PYHDF (PYTHON package)
16 | SKLEARN (PYTHON package)
17 | METEOROLOGICAL DATA (Data)
18 | GEOGRAPHICAL DATA (Data)
19 | IN-SITU MEASURED DATA for CORRECTION (Data)
20 | ### AFAC V2.3
21 | Auxiliary Decision-Making Toolkit for Power System Frequency stability Analysis and Control
22 | A software toolbox developed in Python and Fortran for frequency stability analysis and control of
23 | the power system with high penetration of renewable energy sources.
24 | - Requirements
25 | PYTHON 2.7 (or higher)
26 | PSS/E 33.1 (or higher) or STEPS (https://github.com/changgang/steps)
27 | NUMPY (PYTHON package)
28 | MATPLOTLIB (PYTHON package)
29 | SCIPY (PYTHON package)
30 | SKLEARN (PYTHON package)
31 | POWER FLOW RAW DATA FILES (PSS/E Input Data Files)
32 | DYNAMICS DATA FILES (PSS/E Input Data Files)
33 | ### DLPF V1.1
34 | Deep Learning-Based Toolbox for Power Flow Analysis
35 | A software toolbox developed in Python for optimal search direction and high-convergence and
36 | high-efficiency power flow analysis.
37 | - Requirements
38 | PYTHON 3.9 (or higher)
39 | TKINTER (PYTHON package)
40 | PANDAS (PYTHON package)
41 | TIME (PYTHON package)
42 | SUBPROCESS (PYTHON package)
43 | SKLEARN (PYTHON package)
44 | JOBLIB (PYTHON package)
45 | NUMPY (PYTHON package)
46 | PYPOWER (PYTHON package)
47 | TQDM (PYTHON package)
48 | MATPLOTLIB (PYTHON package)
49 | PYPOWER (PYTHON package)
50 | TQDM (PYTHON package)
51 | TRAIN-LABEL (Data)
52 | TEST-LABEL (Data)
53 |
54 | ## Reference
55 | ## License
56 | [GNU General Public License v3.0](LICENSE)
57 |
--------------------------------------------------------------------------------
/ass_res/CHN_adm_shp/CHN_adm_shp.txt:
--------------------------------------------------------------------------------
1 | The default path of the files of geographical data.
--------------------------------------------------------------------------------
/ass_res/__init__.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python
2 | # -*- coding: utf-8 -*-
3 | """
4 | Created on Sun Jun 11 15:42:16 2017
5 | ########################################################################################
6 | # @ File name: __init_.py
7 | # @ Function: Assess and visualize the spatiotemporal characteristics of regional wind
8 | and solar energy sources to support perliminary regional planning.
9 | # @ Author: Yongji Cao, Hengxu Zhang
10 | # @ Requirements:
11 | # Python 2.7 (or higher)
12 | # numpy (Python package)
13 | # matplotlib (Python package)
14 | # basemap (Python package)
15 | # scipy (Python package)
16 | # pyhdf (Python package)
17 | # sklearn (Python package)
18 | # Ten-year wind speed, solar irradiation and ambient temperature data (Data)
19 | # Geographical data in shapefile file format (Data)
20 | # In-situ measured data for correction (Data)
21 | # @ Version: 1.0
22 | # @ Revision date: Jan/19/2018
23 | # @ Copyright (c) 2016-2018 School of Electrical Engineering, Shandong University, China
24 | ########################################################################################
25 | """
26 |
27 |
28 | __all__ = ['init_nasa_wind', 'init_nasa_solar', 'ass_singlesite_ws',
29 | 'ass_singlesite_lsy', 'draw_geo_fig', 'ass_widearea_dis', 'ass_widearea_wsy']
30 |
--------------------------------------------------------------------------------
/ass_res/ass_singlesite_lsy.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python
2 | # -*- coding: utf-8 -*-
3 | """
4 | Created on Fri Jun 09 18:54:30 2017
5 | ########################################################################################
6 | # @ File name: ass_singlesite_lsy.py
7 | # @ Function: Perform single-site assessment.
8 | # Assess the local synergy effects.
9 | # @ Author: Yongji Cao, Hengxu Zhang
10 | # @ Version: 1.0
11 | # @ Revision date: Jan/19/2018
12 | # @ Copyright (c) 2016-2018 School of Electrical Engineering, Shandong University, China
13 | ########################################################################################
14 | """
15 |
16 |
17 | import numpy as np
18 | import matplotlib.pyplot as plt
19 | from scipy import stats
20 | from mpl_toolkits.axes_grid1 import host_subplot
21 | from sklearn import preprocessing
22 |
23 | import init_nasa_wind as mwind
24 | import init_nasa_solar as msolar
25 | import ass_singlesite_ws as masw
26 |
27 |
28 | def cass_varh_monthly(iwind_data, isolar_data, isiteth_plotted=3, iyear_plotted=2010, plot_flag=False):
29 | '''Assess local synergy of selected sites in month style.
30 | Output graphs
31 | Args:
32 | iwind_data: the source wind data.
33 | isolar_data: the source solar data.
34 | isiteth_plotted: the serial number of selected site.
35 | iyear_plotted: the selected year
36 | plot_flag: True or False. Draw graphs or not.
37 | Returns:
38 | the graphs of monthly variation.
39 | '''
40 | year_index = range(iwind_data.start_year, iwind_data.end_year + 1)
41 | year_num = len(year_index)
42 | site_num = len(iwind_data.site_index)
43 | month_index = iwind_data.month_name
44 | wfc_mean_monthly = np.empty((site_num, 12), np.float32)
45 | wfc_sum_monthly = np.empty((site_num, 12, year_num), np.float32)
46 | sfc_mean_monthly = np.empty((site_num, 12), np.float32)
47 | sfc_sum_monthly = np.empty((site_num, 12, year_num), np.float32)
48 | wfc_ploted = np.empty((1, 12), np.float32)
49 | sfc_ploted = np.empty((1, 12), np.float32)
50 | for each_siteth in range(1, site_num + 1):
51 | for each_monthth in range(0, 12, 1):
52 | for each_year in year_index:
53 | wfc_mean_monthly[each_siteth-1,each_monthth] = \
54 | wfc_mean_monthly[each_siteth-1,each_monthth] + \
55 | np.sum(iwind_data.cselect_1site_1month(each_siteth, each_year, month_index[each_monthth]), axis=1)
56 | wfc_mean_monthly[each_siteth-1,each_monthth] = \
57 | wfc_mean_monthly[each_siteth-1,each_monthth] * 1.0 / year_num
58 | wfc_sum_monthly[each_siteth - 1, each_monthth, each_year - iwind_data.start_year] = \
59 | np.sum(iwind_data.cselect_1site_1month(each_siteth, each_year, month_index[each_monthth]), axis=1)
60 |
61 | sfc_mean_monthly[each_siteth-1,each_monthth] = \
62 | sfc_mean_monthly[each_siteth-1,each_monthth] + \
63 | np.sum(isolar_data.cselect_1site_1month(each_siteth, each_year, month_index[each_monthth]), axis=1)
64 | sfc_mean_monthly[each_siteth-1,each_monthth] = \
65 | sfc_mean_monthly[each_siteth-1,each_monthth] * 1.0 / year_num
66 | sfc_sum_monthly[each_siteth - 1, each_monthth, each_year - iwind_data.start_year] = \
67 | np.sum(isolar_data.cselect_1site_1month(each_siteth, each_year, month_index[each_monthth]), axis=1)
68 | for each_monthth in range(0, 12, 1):
69 | wfc_ploted[0, each_monthth] = \
70 | np.sum(iwind_data.cselect_1site_1month(isiteth_plotted, iyear_plotted, month_index[each_monthth]), axis=1)
71 | sfc_ploted[0, each_monthth] = \
72 | np.sum(isolar_data.cselect_1site_1month(isiteth_plotted, iyear_plotted, month_index[each_monthth]), axis=1)
73 | if plot_flag == True:
74 | plt.rcParams['font.family'] = 'Times New Roman'
75 | plt.figure(dpi=300)
76 | ax1_varann_wfc = host_subplot(111)
77 | ax2_varann_sfc = ax1_varann_wfc.twinx()
78 | width = 1 * 0.43
79 | ind = np.arange(0, 12, 1)
80 | ax1_varann_wfc.bar(ind-width/2.0, wfc_ploted[0, :], width, color='k', label='Wind')
81 | ax2_varann_sfc.bar(ind+width/2.0, sfc_ploted[0, :], width, color='b', label='Solar')
82 | ax1_varann_wfc.set_xticks(np.linspace(0, 11, 12))
83 | ax1_varann_wfc.set_xticklabels(('Jan.', 'Feb.', 'Mar.', 'Apr.', 'May.', 'Jun.', 'Jul.', \
84 | 'Aug.', 'Sep.', 'Oct.', 'Nov.', 'Dec.'))
85 | ax1_varann_wfc.set_xlabel('Month')
86 | ax1_varann_wfc.set_ylabel('Wind capacity factors')
87 | ax2_varann_sfc.set_ylabel('Solar capacity factors')
88 | ax1_varann_wfc.set_xlim(-0.575, 11.575)
89 | #ax1_varann_wfc.grid(True)
90 | ax1_varann_wfc.legend(loc=1)
91 | plt.title('Annual variation')
92 | plt.show()
93 | # plt.savefig('cwp43000.png', dpi=300, bbox_inches='tight')
94 |
95 |
96 | def cass_varh_hourly(iwind_data, isolar_data, isiteth_plotted=3, imonth_ploted='Apr', plot_flag=False):
97 | '''Assess local synergy of selected sites in hour style.
98 | Output graphs.
99 | Args:
100 | iwind_data: the source wind data.
101 | isolar_data: the source solar data.
102 | isiteth_plotted: the serial number of selected site.
103 | imonth_ploted: the selected month
104 | plot_flag: True or False. Draw graphs or not.
105 | Returns:
106 | the graphs of hourly variation.
107 | '''
108 | year_index = range(iwind_data.start_year, iwind_data.end_year + 1)
109 | year_num = len(year_index)
110 | site_num = len(iwind_data.site_index)
111 | wfc_mean_hourly = np.zeros((site_num, year_num, 24), np.float32)
112 | sfc_mean_hourly = np.zeros((site_num, year_num, 24), np.float32)
113 | for each_siteth in range(1, site_num + 1):
114 | for each_yearth in range(0, year_num, 1):
115 | for each_day in range(2, 29, 1):
116 | wfc_mean_hourly[each_siteth - 1, each_yearth, :] = \
117 | wfc_mean_hourly[each_siteth - 1, each_yearth, :] + \
118 | np.hstack((iwind_data.cselect_1site_1day(each_siteth, year_index[each_yearth], imonth_ploted, each_day - 1)[0, 16:24], \
119 | iwind_data.cselect_1site_1day(each_siteth, year_index[each_yearth], imonth_ploted,each_day)[0, 0:16]))
120 | sfc_mean_hourly[each_siteth - 1, each_yearth, :] = \
121 | sfc_mean_hourly[each_siteth - 1, each_yearth, :] + \
122 | np.hstack((isolar_data.cselect_1site_1day(each_siteth, year_index[each_yearth], imonth_ploted, each_day - 1)[0, 16:24], \
123 | isolar_data.cselect_1site_1day(each_siteth, year_index[each_yearth], imonth_ploted, each_day)[0, 0:16]))
124 | wfc_ploted = np.mean(wfc_mean_hourly, axis=1) / 27.0
125 | sfc_ploted = np.mean(sfc_mean_hourly, axis=1) / 27.0
126 | if plot_flag == True:
127 | plt.rcParams['font.family'] = 'Times New Roman'
128 | plt.figure(dpi=300)
129 | ax1_varhour_wfc = host_subplot(111)
130 | ax2_varhour_sfc = ax1_varhour_wfc.twinx()
131 | ind = np.arange(0, 24, 1)
132 | ax1_varhour_wfc.plot(ind, wfc_ploted[isiteth_plotted - 1, :], 'k-o', label='Wind')
133 | ax2_varhour_sfc.plot(ind, sfc_ploted[isiteth_plotted - 1, :], 'b-^', label='Solar')
134 | ax1_varhour_wfc.set_xticks(np.linspace(0, 23, 24))
135 | x_lables=('00:30', '', '02:30', '', '04:30', '', '06:30', '', '08:30', '', '10:30', '', '12:30', '', '14:30', '', '16:30', \
136 | '', '18:30', '', '20:30', '', '22:30', '')
137 | ax1_varhour_wfc.set_xticklabels(x_lables)
138 | ax1_varhour_wfc.set_xlabel('Time')
139 | ax1_varhour_wfc.set_ylabel('Wind capacity factors')
140 | ax2_varhour_sfc.set_ylabel('Solar capacity factors')
141 | ax1_varhour_wfc.set_xlim(-0.7, 23.7)
142 | #plt.grid()
143 | ax1_varhour_wfc.legend(loc=1)
144 | plt.title('Hourly variation')
145 | plt.show()
146 | # plt.savefig('cwp43000.png', dpi=300, bbox_inches='tight')
147 |
148 |
149 | def cass_configh(iwind_data, isolar_data, isiteth_plotted=3, plot_flag=False):
150 | '''Assess local synergy of selected sites.
151 | Search the optimal ratio of wind and solar.
152 | Output statistical indices and graphs.
153 | Args:
154 | iwind_data: the source wind data.
155 | isolar_data: the source solar data.
156 | isiteth_plotted: the serial number of selected site.
157 | plot_flag: True or False. Draw graphs or not.
158 | Returns:
159 | the graphs of hourly variation.
160 | optimal_raio: optimal ratio of wind and solar
161 | '''
162 | wfc_10years = iwind_data.cselect_1site_10year(isiteth_plotted)
163 | sfc_10years = isolar_data.cselect_1site_10year(isiteth_plotted)
164 | wfc_variable_coef = np.std(wfc_10years, axis=1) / np.mean(wfc_10years, axis=1)
165 | sfc_variable_coef = np.std(sfc_10years, axis=1) / np.mean(sfc_10years, axis=1)
166 | hfcvc_list=[]
167 | ind = np.arange(0, 1.02, 0.02)
168 | for each_ratio in ind:
169 | hfc_10years = wfc_10years * each_ratio + sfc_10years * (1 - each_ratio)
170 | hfc_variable_coef = np.std(hfc_10years, axis=1) / np.mean(hfc_10years, axis=1)
171 | hfcvc_list.append(hfc_variable_coef)
172 | optimal_raio = ind[np.argmin(hfcvc_list)]
173 | if plot_flag == True:
174 | plt.rcParams['font.family'] = 'Times New Roman'
175 | plt.figure(dpi=300)
176 | ax = plt.subplot(111)
177 | ax.axhline(y=wfc_variable_coef, xmin=0, xmax=1, color='k', ls='-.', label='Wind')
178 | ax.axhline(y=sfc_variable_coef, xmin=0, xmax=1, color='b', ls='--', label='Solar')
179 | ax.plot(ind, hfcvc_list, color='r', marker='.', label='Wind-Solar')
180 | ax.set_xticks(np.arange(0, 1.1, 0.1))
181 | ax.set_xticklabels((0.0, '', 0.2, '', 0.4, '', 0.6, '', 0.8, '', 1.0))
182 | ax.set_yticks(np.linspace(0.8, 1.4, 4))
183 | ax.set_yticklabels((0.8, 1.0, 1.2, 1.4))
184 | ax.legend(loc=1)
185 | #ax.grid(True)
186 | ax.set_ylabel('Variable coefficient')
187 | ax.set_xlabel('Matching coefficient')
188 | ax.set_xlim(0, 1)
189 | ax.set_ylim(0.7, 1.5)
190 | # plt.savefig('cwp43000.png', dpi=300, bbox_inches='tight')
191 | plt.title('The curve of matching coefficient and variable coefficient')
192 | plt.show()
193 | return optimal_raio
194 |
195 |
196 | def cass_rampopt(iwind_data, isolar_data, ioptimal_ratio, isiteth_plotted=3, plot_flag=False):
197 | '''Assess local synergy of selected sites.
198 | The probability distribution of ramp rate of optimal wind and solar configuration.
199 | Output statistical indices and graphs.
200 | Args:
201 | iwind_data: the source wind data.
202 | isolar_data: the source solar data.
203 | isiteth_plotted: the serial number of selected site.
204 | plot_flag: True or False. Draw graphs or not.
205 | Returns:
206 | the graphs of hourly variation.
207 | hfc_ramp_rate: the ramp rate of optimal wind and solar configuration.
208 | '''
209 | wfc_10years = iwind_data.cselect_1site_10year(isiteth_plotted)
210 | sfc_10years = isolar_data.cselect_1site_10year(isiteth_plotted)
211 | hfc_10years = wfc_10years * ioptimal_ratio + (1 - ioptimal_ratio) * sfc_10years
212 | hfc_10years_tmp = np.hstack((hfc_10years[0, 1:].reshape(-1, 1), hfc_10years[0, 0:-1].reshape(-1, 1)))
213 | hfc_ramp_rate = np.subtract.reduce(hfc_10years_tmp, axis=1)
214 | if plot_flag == True:
215 | plt.rcParams['font.family'] = 'Times New Roman'
216 | plt.figure(dpi = 300)
217 | axh = plt.subplot(111)
218 | cnh,binsh,steph = axh.hist(hfc_ramp_rate, bins=40, normed=True, histtype='barstacked', color='b')
219 | axh.set_ylabel('Probability density')
220 | axh.set_xlabel('Wind-solar ramp rate')
221 | axh.set_xticks(np.arange(-0.2, 0.3, 0.1))
222 | axh.set_xticklabels((-0.2, -0.1, 0.0, 0.1, 0.2))
223 | axh.set_yticks(np.linspace(0, 15, 4))
224 | axh.set_yticklabels((0, 5, 10, 15))
225 | #axh.grid(True)
226 | plt.title('The distribution of ramp rate')
227 | plt.show()
228 | # plt.savefig('cwp43000.png', dpi=300, bbox_inches='tight')
229 | return hfc_ramp_rate
230 |
231 |
232 | def cass_single_site(iwind_data, isolar_data, isiteth=3, ikw=0.60, ikf=0.98, ikc=-0.5, igama=0.1):
233 | '''Assess local synergy of selected sites.
234 | Output statistical indices.
235 | Args:
236 | iwind_data: the source wind data.
237 | isolar_data: the source solar data.
238 | isiteth: the serial number of selected site.
239 | ikw: the profit coefficient of electricity selling of wind energy.
240 | ikf: the profit coefficient of electricity selling of solar energy.
241 | ikc: the negative cost coefficient of ramp reserve.
242 | igama: the weight factor.
243 | Returns:
244 | matching_coef_opt: optimal ratio of wind and solar.
245 | hfc_mean_yearly: means of optimal wind and solar configuration in year scale.
246 | hfc_mean_hourly: means of optimal wind and solar configuration in hour scale.
247 | hfc_std_hourly: std of optimal wind and solar configuration in hour scale.
248 | hfc_varcoef_hourly: variation coefficient of optimal wind and solar configuration in hour scale.
249 | hfc_half_prob: half power probability.
250 | hfc_ramp_rate: the ramp rate of optimal wind and solar configuration.
251 | hfc_ramp_mean: mean of ramp rate.
252 | hfc_ramp_std: std of ramp rate.
253 | hfc_ramp_max: max of ramp rate.
254 | hfc_ramp_min: min of ramp rate.
255 | hfc_ramp_upper: upper value of 95% confidence interval ramp rate.
256 | hfc_ramp_lower: lower value of 95% confidence interval ramp rate.
257 | improving_coef: the improving coefficient.
258 | local_synergy_coef: the local synergy coefficient.
259 | hfc_comp_profits: the comprehensive profit coefficient.
260 | '''
261 | matching_coef_opt = cass_configh(iwind_data, isolar_data, isiteth, False)
262 | hfc_ramp_rate = cass_rampopt(iwind_data, isolar_data, matching_coef_opt, 3, False)
263 | wfc_10years = iwind_data.cselect_1site_10year(isiteth)
264 | sfc_10years = isolar_data.cselect_1site_10year(isiteth)
265 | hfc_10years = wfc_10years * matching_coef_opt + (1 - matching_coef_opt) * sfc_10years
266 | hfc_mean_yearly = np.sum(hfc_10years) / 10.0
267 | hfc_mean_hourly = np.mean(hfc_10years)
268 | hfc_std_hourly = np.std(hfc_10years)
269 | hfc_varcoef_hourly = hfc_mean_hourly * 1.0 / hfc_std_hourly
270 | hfc_half_prob = (hfc_10years[0, hfc_10years[0, :] > 0.5].shape[0]) / (hfc_10years.shape[1])
271 | hfc_ramp_rate = cass_rampopt(wind_data, solar_data, matching_coef_opt, 3, False)
272 | hfc_ramp_mean = np.mean(hfc_ramp_rate)
273 | hfc_ramp_std = np.std(hfc_ramp_rate)
274 | hfc_ramp_max = np.max(hfc_ramp_rate)
275 | hfc_ramp_min = np.min(hfc_ramp_rate)
276 | hfc_ramp_upper = hfc_ramp_mean + 1.96 * hfc_ramp_std
277 | hfc_ramp_lower = hfc_ramp_mean - 1.96 * hfc_ramp_std
278 | wfc_mean_hourly = np.mean(wfc_10years)
279 | wfc_std_hourly = np.std(wfc_10years)
280 | wfc_varcoef_hourly = wfc_mean_hourly * 1.0 / wfc_std_hourly
281 | sfc_mean_hourly = np.mean(sfc_10years)
282 | sfc_std_hourly = np.std(sfc_10years)
283 | sfc_varcoef_hourly = sfc_mean_hourly * 1.0 / sfc_std_hourly
284 | improving_coef = 1 - hfc_varcoef_hourly / (matching_coef_opt * wfc_varcoef_hourly + \
285 | (1 - matching_coef_opt)* sfc_varcoef_hourly)
286 | norwfc_10years = preprocessing.scale(wfc_10years[0, :])
287 | norsfc_10years = preprocessing.scale(sfc_10years[0, :])
288 | local_synergy_coef = 1 - 0.5 * stats.pearsonr(wfc_10years[0, :], sfc_10years[0, :])[0]
289 | Kp = ikw * matching_coef_opt + ikf * (1-matching_coef_opt)
290 | hfc_comp_profits = 1000.0 * (igama * Kp * hfc_mean_hourly + (1 - igama) * ikc * np.mean(hfc_ramp_rate))
291 | return matching_coef_opt, hfc_mean_yearly, hfc_mean_hourly, hfc_std_hourly, hfc_varcoef_hourly, hfc_half_prob, hfc_ramp_rate, \
292 | hfc_ramp_mean, hfc_ramp_std, hfc_ramp_max, hfc_ramp_min, hfc_ramp_upper, hfc_ramp_lower, improving_coef, local_synergy_coef, hfc_comp_profits
293 |
294 |
295 | def cass_attr_constr(iwind_data, isolar_data, imode=0, ikw=0.60, ikf=0.98, ikc=-0.5, igama=0.1):
296 | '''Construct new attirbutes.
297 | Output statistical indices
298 | Args:
299 | iwind_data: the source wind data.
300 | isolar_data: the source solar data.
301 | imode: 0~15
302 | 0 - optimal ratio of wind and solar.
303 | 1 - means of optimal wind and solar configuration in year scale.
304 | 2 - means of optimal wind and solar configuration in hour scale.
305 | 3 - std of optimal wind and solar configuration in hour scale.
306 | 4 - variation coefficient of optimal wind and solar configuration in hour scale.
307 | 5 - half power probability.
308 | 6 - the ramp rate of optimal wind and solar configuration.
309 | 7 - mean of ramp rate.
310 | 8 - std of ramp rate.
311 | 9 - max of ramp rate.
312 | 10 - min of ramp rate.
313 | 11 - upper value of 95% confidence interval ramp rate.
314 | 12 - lower value of 95% confidence interval ramp rate.
315 | 13 - the improving coefficient.
316 | 14 - the local synergy coefficient.
317 | 15 - the comprehensive profit coefficient.
318 | ikw: the profit coefficient of electricity selling of wind energy.
319 | ikf: the profit coefficient of electricity selling of solar energy.
320 | ikc: the negative cost coefficient of ramp reserve.
321 | igama: the weight factor.
322 | Returns:
323 | the constructed attributes.
324 | '''
325 | wf_10yearstl = iwind_data.c2style_10year(True)
326 | sf_10yearstl = isolar_data.c2style_10year(True)
327 | hf_10yearstl = {}
328 | site_num = len(iwind_data.site_index)
329 | # year_index = range(iwind_data.start_year, iwind_data.end_year + 1)
330 | # year_num = len(year_index)
331 | # matching_coef_opt = np.zeros((1, site_num), np.float32)
332 | # interval = np.arange(0, 1.02, 0.02)
333 | analy_results = np.zeros((1, site_num), np.float32)
334 | for each_siteth in range(1, site_num + 1, 1):
335 | (oindices0, oindices1, oindices2, oindices3, oindices4, oindices5, oindices6, oindices7, \
336 | oindices8, oindices9, oindices10, oindices11, oindices12, oindices13, oindices14, oindices15) =\
337 | cass_single_site(iwind_data, isolar_data, each_siteth, ikw, ikf, ikc, igama)
338 | if imode == 0:
339 | analy_results[0, each_siteth] = oidices0
340 | elif imode == 1:
341 | analy_results[0, each_siteth] = oidices1
342 | elif imode == 2:
343 | analy_results[0, each_siteth] = oidices2
344 | elif imode == 3:
345 | analy_results[0, each_siteth] = oidices3
346 | elif imode == 4:
347 | analy_results[0, each_siteth] = oidices4
348 | elif imode == 5:
349 | analy_results[0, each_siteth] = oidices5
350 | elif imode == 6:
351 | analy_results[0, each_siteth] = oidices6
352 | elif imode == 7
353 | analy_results[0, each_siteth] = oidices7
354 | elif imode == 8:
355 | analy_results[0, each_siteth] = oidices8
356 | elif imode == 9:
357 | analy_results[0, each_siteth] = oidices9
358 | elif imode == 10:
359 | analy_results[0, each_siteth] = oidices10
360 | elif imode == 11:
361 | analy_results[0, each_siteth] = oidices11
362 | elif imode == 12:
363 | analy_results[0, each_siteth] = oidices12
364 | elif imode == 13:
365 | analy_results[0, each_siteth] = oidices13
366 | elif imode == 14:
367 | analy_results[0, each_siteth] = oidices14
368 | # elif imode == 15:
369 | else:
370 | analy_results[0, each_siteth] = oidices15
371 | return analy_results
372 |
373 |
374 | def cass_output_prob(iwind_data, isolar_data, isiteth=3):
375 | '''Assess local synergy of selected sites.
376 | The probability distribution of capacity factors.
377 | Output statistical indices
378 | Args:
379 | iwind_data: the source wind data.
380 | isolar_data: the source solar data.
381 | isiteth: the serial number of selected site.
382 | Returns:
383 | the garphs of pdfs and cdfs.
384 | '''
385 | matching_coef_opt = cass_configh(iwind_data, isolar_data, isiteth, False)
386 | wfc_10years = iwind_data.cselect_1site_10year(isiteth)
387 | sfc_10years = isolar_data.cselect_1site_10year(isiteth)
388 | hfc_10years = wfc_10years * matching_coef_opt + (1 - matching_coef_opt) * sfc_10years
389 | wfc_output = np.empty((0,),np.float32)
390 | sfc_output = np.empty((0,),np.float32)
391 | hfc_output = np.empty((0,),np.float32)
392 | interval = np.arange(-0, 1.05, 0.05)
393 | for each in interval:
394 | hfc_output = np.hstack((hfc_output,(hfc_10years[0, hfc_10years[0, :] <= each].shape[0] * 100.0 / hfc_10years.shape[1])))
395 | sfc_output = np.hstack((sfc_output,(sfc_10years[0, sfc_10years[0, :] <= each].shape[0] * 100.0 / sfc_10years.shape[1])))
396 | wfc_output = np.hstack((wfc_output,(wfc_10years[0, wfc_10years[0, :] <= each].shape[0] * 100.0 / wfc_10years.shape[1])))
397 | plt.rcParams['font.family'] = 'Times New Roman'
398 | plt.figure(dpi=300)
399 | plt.title('The PDF and CDF of capacity factors', fontsize=8)
400 | ax1 = plt.subplot(221)
401 | cn1, bins1, step1 = ax1.hist(wfc_10years.reshape(-1, 1), bins=20, normed=True, histtype='barstacked', color='b')
402 | ax1.set_xticks(np.linspace(0,1,6))
403 | ax1.set_xticklabels((0.0, 0.2, 0.4, 0.6, 0.8, 1.0), rotation=0, fontsize=8)
404 | ax1.set_yticks(np.linspace(0, 4, 5))
405 | ax1.set_yticklabels((0, 1, 2, 3, 4), rotation=90, fontsize=8)
406 | ax1.set_xlim(-0.005, 1.005)
407 | ax1.set_ylim(-0.005, 4.5)
408 | ax1.set_xlabel('Wind capacity factor\n(a)', fontsize=8)
409 | ax1.set_ylabel('Probability density', fontsize=8)
410 | ax2 = plt.subplot(222)
411 | cn2, bins2, step2 = ax2.hist(sfc_10years.reshape(-1, 1), bins=20 , normed=True, histtype='stepfilled', color='b')
412 | ax2.set_xticks(np.linspace(0, 1, 6))
413 | ax2.set_xticklabels((0.0, 0.2, 0.4, 0.6, 0.8, 1.0), rotation=0, fontsize=8)
414 | ax2.set_yticks(np.linspace(0, 4, 5))
415 | ax2.set_yticklabels((0, 1, 2, 3, 4), rotation=90, fontsize=8)
416 | ax2.set_xlim(-0.005, 1.005)
417 | ax2.set_ylim(-0.005, 4.5)
418 | ax2.set_xlabel('Solar capacity factor\n(b)', fontsize=8)
419 | ax2.set_ylabel('Probability density', fontsize=8)
420 | ax3 = plt.subplot(223)
421 | cn3, bins3, step3 = ax3.hist(hfc_10years.reshape(-1, 1), bins=20, normed=True, histtype='stepfilled', color='b')
422 | ax3.set_xticks(np.linspace(0, 1, 6))
423 | ax3.set_xticklabels((0.0, 0.2, 0.4, 0.6, 0.8, 1.0), rotation=0, fontsize=8)
424 | ax3.set_yticks(np.linspace(0, 4, 5))
425 | ax3.set_yticklabels((0, 1, 2, 3, 4), rotation=90, fontsize=8)
426 | ax3.set_xlim(-0.005, 1.005)
427 | ax3.set_ylim(-0.005, 4.5)
428 | ax3.set_xlabel('Wind-solar capacity factor\n(c)', fontsize=8)
429 | ax3.set_ylabel('Probability density', fontsize=8)
430 | ax4 = plt.subplot(224)
431 | ax4.plot(interval, wfc_output, 'k-o', label='Wind', markersize=3, linewidth=1)
432 | ax4.plot(interval, sfc_output, 'b-^', label='Solar', markersize=3, linewidth=1)
433 | ax4.plot(interval, hfc_output, 'r-d', label='Wind-solar', markersize=3, linewidth=1)
434 | ax4.legend(fontsize=6, loc=4, ncol=1)
435 | ax4.set_xticks(np.linspace(0, 1, 5))
436 | ax4.set_xticklabels((0.0, 0.25, 0.5, 0.75, 1.00), rotation=0, fontsize=8)
437 | ax4.set_yticks(np.linspace(0, 100, 6))
438 | ax4.set_yticklabels((0, 20, 40, 60, 80,100), rotation=90, fontsize=8)
439 | ax4.set_xlim(-0.025, 1.005)
440 | ax4.set_ylim(-2.5, 105)
441 | ax4.set_xlabel('Capacity factor\n(d)', fontsize=8)
442 | ax4.set_ylabel('Probability (%)', fontsize=8)
443 | plt.subplots_adjust(wspace=0.25, hspace=0.42)
444 | plt.show()
445 | # plt.savefig('cPlotHNew0.png', dpi=300, bbox_inches='tight')
446 |
447 |
448 | if __name__ == '__main__':
449 | '''Examples.'''
450 | start_year = 2006
451 | end_year = 2015
452 | site_index = [(-6, 2), (-6, 6), (-6, 10)]
453 | wfile_name = 'sd_wind_data'
454 | sfile_name = 'sd_solar_data'
455 |
456 | wind_data = mwind.WindData(wfile_name, site_index, start_year, end_year)
457 | wind_speed_ref = wind_data.cimport_data()
458 | wind_speed_hw = wind_data.cref2hw()
459 | wind_capacity_factor = wind_data.cwind2cf()
460 | solar_data = msolar.SolarData(sfile_name, site_index, start_year, end_year)
461 | solar_irrad_data = solar_data.cimport_data()
462 | solar_capacity_factor = solar_data.csolar2cf_model1()
463 | # solar_temperature_data = solar_data.cimport_datat()
464 | # solar_capacity_factor = solar_data.csolar2cf_model2()
465 |
466 | cass_single_site(wind_data, solar_data, 3)
467 | cass_varh_monthly(wind_data, solar_data, 3, 2010, True)
468 | cass_varh_hourly(wind_data, solar_data, 3, 'Apr', True)
469 | optimal_raio = cass_configh(wind_data, solar_data, 3, True)
470 | print optimal_raio
471 | hfc_ramp_rate = cass_rampopt(wind_data, solar_data, optimal_raio, 3, True)
472 | assess_result = cass_single_site(wind_data, solar_data, 3)
473 | attr = cass_attr_constr(wind_data, solar_data, 0)
474 | cass_output_prob(wind_data, solar_data, 3)
475 |
--------------------------------------------------------------------------------
/ass_res/ass_singlesite_ws.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python
2 | # -*- coding: utf-8 -*-
3 | """
4 | Created on Fri Jun 09 18:51:22 2017
5 | ########################################################################################
6 | # @ File name: ass_singlesite_ws.py
7 | # @ Function: Perform single-site assessment.
8 | # Assess the variation and reserves of wind and solar resources.
9 | # @ Author: Yongji Cao, Hengxu Zhang
10 | # @ Version: 1.0
11 | # @ Revision date: Jan/19/2018
12 | # @ Copyright (c) 2016-2018 School of Electrical Engineering, Shandong University, China
13 | ########################################################################################
14 | """
15 |
16 |
17 | import numpy as np
18 | import matplotlib.pyplot as plt
19 | from mpl_toolkits.axes_grid1 import host_subplot
20 |
21 | import init_nasa_wind as mwind
22 | import init_nasa_solar as msolar
23 |
24 |
25 | def cass_varws_annual(isource_data, isiteth_plotted=[1, 2, 3], plot_flag=False):
26 | '''Assess annual variation of selected sites.
27 | Output statistical indices and graphs
28 | Args:
29 | isource_data: the source data.
30 | isiteth_plotted: the serial number of selected site.
31 | plot_flag: True or False. Draw graphs or not.
32 | Returns:
33 | the graphs of annual variation.
34 | means, std, and variable coefficient of selected site in year scale.
35 | '''
36 | year_index = range(isource_data.start_year, isource_data.end_year + 1)
37 | year_num = len(year_index)
38 | site_num = len(isource_data.site_index)
39 | fc_sum_yearly = np.empty((site_num, year_num), np.float32)
40 | fc_mean_yearly = np.empty((site_num, 1), np.float32)
41 | fc_std_yearly = np.empty((site_num, 1), np.float32)
42 | fc_varcoef_yearly = np.empty((site_num, 1), np.float32)
43 | for each_siteth in range(1, site_num + 1):
44 | for each_yearth in range(0, year_num, 1):
45 | fc_sum_yearly[each_siteth - 1, each_yearth] = \
46 | np.sum(isource_data.cselect_1site_1year(each_siteth, year_index[each_yearth]), axis=1)
47 | fc_mean_yearly[each_siteth - 1, 0] = \
48 | np.sum(isource_data.cselect_1site_10year(each_siteth), axis=1) / year_num
49 | fc_std_yearly[each_siteth - 1, 0] = \
50 | np.std(fc_sum_yearly[each_siteth - 1, :])
51 | fc_varcoef_yearly[each_siteth - 1, 0] = \
52 | fc_std_yearly[each_siteth - 1, 0] * 1.0 / fc_mean_yearly[each_siteth - 1, 0]
53 | if plot_flag == True:
54 | plt.rcParams['font.family'] = 'Times New Roman'
55 | plt.figure(dpi=300)
56 | ax = plt.subplot(111)
57 | width = 1 * 0.25 * 3 / site_num
58 | ind = np.arange(0, year_num, 1)
59 | if len(isiteth_plotted) == 3:
60 | ax.bar(ind - width, fc_sum_yearly[isiteth_plotted[0] - 1, :], width,
61 | color='k', label='Siteth ' + str(isiteth_plotted[0]))
62 | ax.bar(ind, fc_sum_yearly[isiteth_plotted[1] - 1, :], width,
63 | color='b', label='Siteth ' + str(isiteth_plotted[1]))
64 | ax.bar(ind + width, fc_sum_yearly[isiteth_plotted[2] - 1, :], width,
65 | color='r', label='Siteth ' + str(isiteth_plotted[2]))
66 | elif len(isiteth_plotted) == 2:
67 | ax.bar(ind - width, fc_sum_yearly[isiteth_plotted[0] - 1, :], width,
68 | color='k', label='Siteth ' + str(isiteth_plotted[0]))
69 | ax.bar(ind, fc_sum_yearly[isiteth_plotted[1] - 1, :], width,
70 | color='b', label='Siteth ' + str(isiteth_plotted[1]))
71 | else:
72 | ax.bar(ind, fc_sum_yearly[isiteth_plotted[0] - 1, :], width,
73 | color='k', label='Siteth ' + str(isiteth_plotted[0]))
74 | ax.set_xticks(np.linspace(0, 9, 10))
75 | x_lable = tuple([str(each) for each in year_index])
76 | ax.set_xticklabels(x_lable)
77 | ax.set_xlabel('Year')
78 | ax.set_ylabel('Capacity factors')
79 | # ax.grid(True)
80 | ax.legend(loc=1)
81 | plt.title('The annual variation')
82 | plt.show()
83 | # plt.savefig('cPlotW1.png', dpi=300, bbox_inches='tight')
84 | if isinstance(isiteth_plotted, list):
85 | ositeth_plotted = [each - 1 for each in list(isiteth_plotted)]
86 | else:
87 | ositeth_plotted = isiteth_plotted - 1
88 | return fc_mean_yearly[ositeth_plotted, 0], fc_std_yearly[ositeth_plotted, 0], fc_varcoef_yearly[ositeth_plotted, 0]
89 |
90 |
91 | def cass_varws_monthly(isource_data, isiteth_plotted=[1, 2, 3], iyear_plotted=2010, plot_flag=False):
92 | '''Assess monthly variation of selected sites, selected year.
93 | Output graphs
94 | Args:
95 | isource_data: the source data.
96 | isiteth_plotted: the serial number of selected site.
97 | iyear_plotted: the selected year.
98 | plot_flag: True or False. Draw graphs or not.
99 | Returns:
100 | the graphs of monthly variation.
101 | '''
102 | year_index = range(isource_data.start_year, isource_data.end_year + 1)
103 | year_num = len(year_index)
104 | site_num = len(isource_data.site_index)
105 | month_index = isource_data.month_name
106 | fc_mean_monthly = np.empty((site_num, 12), np.float32)
107 | fc_sum_monthly = np.empty((site_num, 12, year_num), np.float32)
108 | fc_ploted = np.empty((site_num, 12), np.float32)
109 | for each_siteth in range(1, site_num + 1):
110 | for each_monthth in range(0, 12, 1):
111 | for each_year in year_index:
112 | fc_mean_monthly[each_siteth - 1, each_monthth] = \
113 | fc_mean_monthly[each_siteth - 1, each_monthth] + \
114 | np.sum(isource_data.cselect_1site_1month(each_siteth, each_year, month_index[each_monthth]), axis=1)
115 | fc_mean_monthly[each_siteth - 1, each_monthth] = \
116 | fc_mean_monthly[each_siteth - 1, each_monthth] * 1.0 / year_num
117 | fc_sum_monthly[each_siteth - 1, each_monthth, each_year - isource_data.start_year] = \
118 | np.sum(isource_data.cselect_1site_1month(each_siteth, each_year, month_index[each_monthth]), axis=1)
119 | for each_plotsiteth in isiteth_plotted:
120 | for each_monthth in range(0, 12, 1):
121 | fc_ploted[each_plotsiteth - 1, each_monthth] = \
122 | np.sum(isource_data.cselect_1site_1month(each_plotsiteth, iyear_plotted, month_index[each_monthth]), axis=1)
123 | if plot_flag == True:
124 | plt.rcParams['font.family'] = 'Times New Roman'
125 | plt.figure(dpi=300)
126 | ax=plt.subplot(111)
127 | width = 1 * 0.25 * 3 / site_num
128 | ind = np.arange(0, 12, 1)
129 | if len(isiteth_plotted) == 3:
130 | ax.bar(ind - width, fc_ploted[isiteth_plotted[0] - 1, :], width,
131 | color='k', label='Siteth ' + str(isiteth_plotted[0]))
132 | ax.bar(ind, fc_ploted[isiteth_plotted[1] - 1, :], width,
133 | color='b', label='Siteth ' + str(isiteth_plotted[1]))
134 | ax.bar(ind + width, fc_ploted[isiteth_plotted[2] - 1, :], width,
135 | color='r', label='Siteth ' + str(isiteth_plotted[2]))
136 | elif len(isiteth_plotted) == 2:
137 | ax.bar(ind - width, fc_ploted[isiteth_plotted[0] - 1, :], width,
138 | color='k', label='Siteth ' + str(isiteth_plotted[0]))
139 | ax.bar(ind, fc_ploted[isiteth_plotted[1] - 1, :], width,
140 | color='b', label='Siteth ' + str(isiteth_plotted[1]))
141 | else:
142 | ax.bar(ind, fc_ploted[isiteth_plotted[0] - 1, :], width,
143 | color='k', label='Siteth ' + str(isiteth_plotted[0]))
144 | ax.set_xticks(np.linspace(0, 11, 12))
145 | ax.set_xticklabels(('Jan.', 'Feb.', 'Mar.', 'Apr.', 'May.', 'Jun.', 'Jul.',
146 | 'Aug.', 'Sep.', 'Oct.', 'Nov.', 'Dec.'), rotation=45, fontsize=8)
147 | ax.set_xlabel('Month')
148 | ax.set_ylabel('Capacity factors')
149 | # ax.grid(True)
150 | ax.legend(loc=1)
151 | plt.title('The monthly variation')
152 | plt.show()
153 | # plt.savefig('cPlotW1.png', dpi=300, bbox_inches='tight')
154 |
155 |
156 | def cass_varws_hourly(isource_data, isiteth_plotted=[1, 2, 3], imonth_ploted='Apr', plot_flag=False):
157 | '''Assess hourly variation of selected sites, selected month.
158 | Output graphs
159 | Args:
160 | isource_data: the source data.
161 | isiteth_plotted: the serial number of selected site.
162 | imonth_ploted: the selected month.
163 | plot_flag: True or False. Draw graphs or not.
164 | Returns:
165 | the graphs of monthly variation.
166 | '''
167 | year_index = range(isource_data.start_year, isource_data.end_year + 1)
168 | year_num = len(year_index)
169 | site_num = len(isource_data.site_index)
170 | fc_mean_hourly = np.zeros((site_num, year_num, 24), np.float32)
171 | for each_siteth in range(1, site_num + 1):
172 | for each_yearth in range(0, year_num, 1):
173 | for each_day in range(2, 29, 1):
174 | fc_mean_hourly[each_siteth - 1, each_yearth, :] = \
175 | fc_mean_hourly[each_siteth - 1, each_yearth, :] + \
176 | np.hstack((isource_data.cselect_1site_1day(each_siteth,year_index[each_yearth], imonth_ploted,each_day-1)[0, 16:24], \
177 | isource_data.cselect_1site_1day(each_siteth, year_index[each_yearth], imonth_ploted, each_day)[0, 0:16]))
178 | fc_ploted = np.mean(fc_mean_hourly, axis=1) / 27.0
179 | if plot_flag == True:
180 | plt.rcParams['font.family'] = 'Times New Roman'
181 | plt.figure(dpi=300)
182 | ax = host_subplot(111)
183 | ind = np.arange(0, 24, 1)
184 | if len(isiteth_plotted) == 3:
185 | ax.plot(ind, fc_ploted[isiteth_plotted[0] - 1, :], 'k-o', label='Siteth ' + str(isiteth_plotted[0]))
186 | ax.plot(ind, fc_ploted[isiteth_plotted[1] - 1, :], 'b-^', label='Siteth ' + str(isiteth_plotted[1]))
187 | ax.plot(ind, fc_ploted[isiteth_plotted[2] - 1, :], 'r-d', label='Siteth ' + str(isiteth_plotted[2]))
188 | elif len(isiteth_plotted) == 2:
189 | ax.plot(ind, fc_ploted[isiteth_plotted[0] - 1, :], 'k-o', label='Siteth ' + str(isiteth_plotted[0]))
190 | ax.plot(ind, fc_ploted[isiteth_plotted[1] - 1, :], 'b-^', label='Siteth ' + str(isiteth_plotted[1]))
191 | else:
192 | ax.plot(ind, fc_ploted[isiteth_plotted[0] - 1, :], 'k-o', label='Siteth ' + str(isiteth_plotted[0]))
193 | ax.set_xticks(np.linspace(0, 23, 24))
194 | x_lables=('00:30', '', '02:30', '', '04:30', '', '06:30', '', '08:30', '', '10:30', \
195 | '', '12:30', '', '14:30', '', '16:30', '', '18:30', '', '20:30', '', '22:30', '')
196 | ax.set_xticklabels(x_lables)
197 | ax.set_xlabel('Time')
198 | ax.set_ylabel('Wind capacity factors')
199 | ax.set_xlim(-0.7, 23.7)
200 | #plt.grid()
201 | ax.legend(loc = 1)
202 | plt.title('The hourly variation')
203 | plt.show()
204 | # plt.savefig('cwp43000.png', dpi=300, bbox_inches='tight')
205 |
206 |
207 | def cass_rampws(isource_data, isiteth_plotted=3, plot_flag=False):
208 | '''Assess ramp rate of selected sites.
209 | Output statistical indices and graphs
210 | Args:
211 | isource_data: the source data.
212 | isiteth_plotted: the serial number of selected site.
213 | plot_flag: True or False. Draw graphs or not.
214 | Returns:
215 | the graphs of monthly variation.
216 | fc_ramp_rate: ramp rate.
217 | '''
218 | fc_10years = isource_data.cselect_1site_10year(isiteth_plotted)
219 | fc_10years_tmp = np.hstack((fc_10years[0, 1:].reshape(-1, 1), fc_10years[0, 0:-1].reshape(-1, 1)))
220 | fc_ramp_rate = np.subtract.reduce(fc_10years_tmp, axis=1)
221 | if plot_flag == True:
222 | plt.rcParams['font.family'] = 'Times New Roman'
223 | plt.figure(dpi=300)
224 | ax = plt.subplot(111)
225 | cn, bins, step = ax.hist(fc_ramp_rate, bins=40, normed=True, histtype='barstacked', color='b')
226 | ax.set_ylabel('Probability density')
227 | ax.set_xlabel('ramp rate')
228 | ax.set_xticks(np.arange(-0.2, 0.3, 0.1))
229 | ax.set_xticklabels((-0.2, -0.1, 0.0, 0.1, 0.2))
230 | ax.set_yticks(np.linspace(0, 15, 4))
231 | ax.set_yticklabels((0, 5, 10, 15))
232 | #ax.grid(True)
233 | plt.title('The distribution of ramp rate')
234 | plt.show()
235 | # plt.savefig('cwp43000.png', dpi=300, bbox_inches='tight')
236 | return fc_ramp_rate
237 |
238 |
239 | def cass_single_site(isource_data, isiteth=3):
240 | '''Assess selected sites.
241 | Output statistical indices
242 | Args:
243 | isource_data: the source data.
244 | isiteth: the serial number of selected site.
245 | Returns:
246 | fc_mean_yearly: means of selected site in year scale.
247 | fc_std_yearly: std of selected site in year scale.
248 | fc_varcoef_yearly: variable coefficient of selected site in year scale.
249 | fc_mean_hourly: means of selected site in hour scale.
250 | fc_std_hourly: std of selected site in hour scale.
251 | fc_varcoef_hourly: variable coefficient of selected site in hour scale.
252 | fc_half_prob: half power probability.
253 | fc_ramp_rate: ramp rate.
254 | fc_ramp_mean: mean of ramp rate.
255 | fc_ramp_std: std of ramp rate.
256 | fc_ramp_max: max of ramp rate.
257 | fc_ramp_min: min of ramp rate.
258 | fc_ramp_upper: upper value of 95% confidence interval ramp rate.
259 | fc_ramp_lower: lower value of 95% confidence interval ramp rate.
260 | '''
261 | (fc_mean_yearly, fc_std_yearly, fc_varcoef_yearly) = cass_varws_annual(isource_data, isiteth, False)
262 | fc_10years = isource_data.cselect_1site_10year(isiteth)
263 | fc_mean_hourly = np.mean(fc_10years)
264 | fc_std_hourly = np.std(fc_10years)
265 | fc_varcoef_hourly = fc_mean_hourly * 1.0 / fc_std_hourly
266 | fc_half_prob = (fc_10years[0, fc_10years[0, :] > 0.5].shape[0] * 1.0)/ (fc_10years.shape[1] * 1.0)
267 | fc_ramp_rate = cass_rampws(isource_data, isiteth, False)
268 | fc_ramp_mean = np.mean(np.abs(fc_ramp_rate))
269 | fc_ramp_std = np.std(fc_ramp_rate)
270 | fc_ramp_max = np.max(fc_ramp_rate)
271 | fc_ramp_min = np.min(fc_ramp_rate)
272 | fc_ramp_upper = fc_ramp_mean + 1.96 * fc_ramp_std
273 | fc_ramp_lower = fc_ramp_mean - 1.96 * fc_ramp_std
274 | return fc_mean_yearly, fc_std_yearly, fc_varcoef_yearly, fc_mean_hourly, fc_std_hourly, fc_varcoef_hourly, \
275 | fc_half_prob, fc_ramp_rate, fc_ramp_mean, fc_ramp_std, fc_ramp_max, fc_ramp_min, fc_ramp_upper, fc_ramp_lower
276 |
277 |
278 | def cass_attr_constr(isource_data, imode=0):
279 | '''Construct new attirbutes.
280 | Output statistical indices
281 | Args:
282 | isource_data: the source data.
283 | imode: 0, 1, 2, 3. means in year scale, std in hour scale, variable coefficient in hour scale, means in hour scale
284 | Returns:
285 | the constructed attributes.
286 | '''
287 | cf_10yearstl = isource_data.c2style_10year(True)
288 | year_index = range(isource_data.start_year, isource_data.end_year + 1)
289 | year_num = len(year_index)
290 | site_num = len(isource_data.site_index)
291 | if imode == 0:
292 | fc_mean_yearly = np.zeros((1, site_num), np.float32)
293 | for each_siteth in range(1, site_num + 1, 1):
294 | fc_mean_yearly[0, each_siteth-1] = \
295 | np.sum(cf_10yearstl[each_siteth], axis=1) * 1.0 / year_num
296 | return fc_mean_yearly
297 | elif imode == 1:
298 | fc_std_hourly = np.zeros((1, site_num), np.float32)
299 | for each_siteth in range(1, site_num + 1, 1):
300 | fc_std_hourly[0, each_siteth-1] = \
301 | np.std(cf_10yearstl[each_siteth], axis=1) * 1.0
302 | return fc_std_hourly
303 | elif imode == 2:
304 | fc_varcoef_hourly = np.zeros((1, site_num), np.float32)
305 | for each_siteth in range(1, site_num + 1, 1):
306 | fc_varcoef_hourly[0, each_siteth-1] = \
307 | np.std(cf_10yearstl[each_siteth], axis=1) * 1.0 / np.mean(cf_10yearstl[each_siteth], axis=1)
308 | return fc_varcoef_hourly
309 | else:
310 | fc_mean_hourly = np.zeros((1, site_num), np.float32)
311 | for each_siteth in range(1, site_num + 1, 1):
312 | fc_mean_hourly[0, each_siteth-1] = \
313 | np.mean(cf_10yearstl[each_siteth], axis=1)
314 | return fc_mean_hourly
315 |
316 |
317 | if __name__ == '__main__':
318 | '''Examples.'''
319 | start_year = 2006
320 | end_year = 2015
321 | site_index = [(-6, 2), (-6, 6), (-6, 10)]
322 | wfile_name = 'sd_wind_data'
323 | sfile_name = 'sd_solar_data'
324 |
325 | wind_data = mwind.WindData(wfile_name, site_index, start_year, end_year)
326 | wind_speed_ref = wind_data.cimport_data()
327 | wind_speed_hw = wind_data.cref2hw()
328 | wind_capacity_factor = wind_data.cwind2cf()
329 | solar_data = msolar.SolarData(sfile_name, site_index, start_year, end_year)
330 | solar_irrad_data = solar_data.cimport_data()
331 | solar_capacity_factor = solar_data.csolar2cf_model1()
332 | # solar_temperature_data = solar_data.cimport_datat()
333 | # solar_capacity_factor = solar_data.csolar2cf_model2()
334 |
335 | (fc_mean_yearly, fc_std_yearly, fc_varcoef_yearly) = cass_varws_annual(wind_data, [1,2,3], True)
336 | cass_varws_monthly(wind_data, [1,2,3], 2010, True)
337 | cass_varws_hourly(wind_data, [1,2,3], 'Apr', True)
338 | fc_ramp_rate = cass_rampws(wind_data, 3, True)
339 | assess_result = cass_single_site(wind_data, 3)
340 | attr = cass_attr_constr(wind_data, 0)
341 |
342 |
343 |
--------------------------------------------------------------------------------
/ass_res/ass_widearea_dis.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python
2 | # -*- coding: utf-8 -*-
3 | """
4 | Created on Sat Jun 10 09:31:51 2017
5 | ########################################################################################
6 | # @ File name: ass_widearea_dis.py
7 | # @ Function: Perform wide-area assessment.
8 | # Assess the spatial distribution of resources, local synergy effects,
9 | # and the spatial effects of one site.
10 | # @ Author: Yongji Cao, Hengxu Zhang
11 | # @ Version: 1.0
12 | # @ Revision date: Jan/19/2018
13 | # @ Copyright (c) 2016-2018 School of Electrical Engineering, Shandong University, China
14 | ########################################################################################
15 | """
16 |
17 |
18 | import numpy as np
19 |
20 | import init_nasa_wind as mwind
21 | import init_nasa_solar as msolar
22 | import draw_geo_fig as mdgf
23 | import ass_singlesite_ws as masw
24 | import ass_singlesite_lsy as maslsy
25 | import ass_widearea_wsy as mawwsy
26 |
27 |
28 | def ass_wide_ws(isource_data, ioutline, inames, ilat_lable, ilon_lable, isite_lon, isite_lat, imode=0):
29 | '''Assess the spatial distribution of wind and solar resources.
30 | Output statistical indices and graphs.
31 | Args:
32 | isource_data: the source data.
33 | ioutline: the outlines of the background.
34 | inames: the filename of geographical data, attribute/column name, and region name.
35 | ilat_lable: the latitude label.
36 | ilon_lable: the longitude label.
37 | isite_lon: the longitude of the annotated site.
38 | isite_lat: the latitude of the annotated sites.
39 | imode: 0, 1, 2, 3. means in year scale, std in hour scale, variable coefficient in hour scale, means in hour scale
40 | Returns:
41 | the graphs.
42 | attri: the selected attribute.
43 | the max value of the selected attribute.
44 | the serial number of site of the max value.
45 | the min value of the selected attribute.
46 | the serial number of site of the min value.
47 | '''
48 | attri = masw.cass_attr_constr(isource_data, imode)
49 | mdgf.cdraw_contour_fig(attri, ioutline, inames, ilat_lable, ilon_lable, isite_lon, isite_lat)
50 | return attri, np.max(attri, axis=1), np.argmax(attri, axis=1) + 1, \
51 | np.min(attri, axis=1), np.argmin(attri, axis=1) + 1
52 |
53 |
54 | def ass_wide_lsy(iwind_data, isolar_data, ioutline, inames, ilat_lable, ilon_lable, isite_lon, isite_lat, imode=0, ikw=0.60, ikf=0.98, ikc=-0.5, igama=0.1):
55 | '''Assess the spatial distribution of local synergy effects.
56 | Output statistical indices and graphs.
57 | Args:
58 | iwind_data: the source wind data.
59 | isolar_data: the source solar data.
60 | ioutline: the outlines of the background.
61 | inames: the filename of geographical data, attribute/column name, the region name.
62 | ilat_lable: the latitude label.
63 | ilon_lable: the longitude label.
64 | isite_lon: the longitude of the annotated site.
65 | isite_lat: the latitude of the annotated sites.
66 | imode: 0~15
67 | 0 - optimal ratio of wind and solar.
68 | 1 - means of optimal wind and solar configuration in year scale.
69 | 2 - means of optimal wind and solar configuration in hour scale.
70 | 3 - std of optimal wind and solar configuration in hour scale.
71 | 4 - variation coefficient of optimal wind and solar configuration in hour scale.
72 | 5 - half power probability.
73 | 6 - the ramp rate of optimal wind and solar configuration.
74 | 7 - mean of ramp rate.
75 | 8 - std of ramp rate.
76 | 9 - max of ramp rate.
77 | 10 - min of ramp rate.
78 | 11 - upper value of 95% confidence interval ramp rate.
79 | 12 - lower value of 95% confidence interval ramp rate.
80 | 13 - the improving coefficient.
81 | 14 - the local synergy coefficient.
82 | 15 - the comprehensive profit coefficient.
83 | ikw: the profit coefficient of electricity selling of wind energy.
84 | ikf: the profit coefficient of electricity selling of solar energy.
85 | ikc: the negative cost coefficient of ramp reserve.
86 | igama: the weight factor.
87 | Returns:
88 | the graphs.
89 | attri: the selected attribute.
90 | the max value of the selected attribute.
91 | the serial number of site of the max value.
92 | the min value of the selected attribute.
93 | the serial number of site of the min value.
94 | '''
95 | attri = maslsy.cass_attr_constr(iwind_data, isolar_data, imode, ikw, ikf, ikc, igama)
96 | mdgf.cdraw_contour_fig(attri, ioutline, inames, ilat_lable, ilon_lable, isite_lon, isite_lat)
97 | return attri, np.max(attri, axis=1), np.argmax(attri, axis=1) + 1, \
98 | np.min(attri, axis=1), np.argmin(attri, axis=1) + 1
99 |
100 |
101 | def ass_site_wsy(iwind_data, isolar_data, ioutline, inames, ilat_lable, ilon_lable, isite_lon, isite_lat, isiteth=71, imode=0):
102 | '''Assess the spatial distribution of the spatial effects of a selected site.
103 | Output statistical indices and graphs.
104 | Args:
105 | iwind_data: the source wind data.
106 | isolar_data: the source solar data.
107 | ioutline: the outlines of the background.
108 | inames: the filename of geographical data, attribute/column name, and region name.
109 | ilat_lable: the latitude label.
110 | ilon_lable: the longitude label.
111 | isite_lon: the longitude of the annotated site.
112 | isite_lat: the latitude of the annotated sites.
113 | isiteth: the serial number of the selected site.
114 | imode: 0, 1, 2, 3. the spatial wind-wind synergy coefficient, spatial solar-solar synergy coefficient,
115 | spatial wind-solar synergy coefficient, spatial solar-wind synergy coefficient
116 | Returns:
117 | the graphs.
118 | attri: the selected attribute.
119 | the max value of the selected attribute.
120 | the serial number of site of the max value.
121 | the min value of the selected attribute.
122 | the serial number of site of the min value.
123 | '''
124 | attri = mawwsy.ccalc_synergy_coef(iwind_data, isolar_data, imode, isiteth)
125 | mdgf.cdraw_contour_fig(attri, ioutline, inames, ilat_lable, ilon_lable, isite_lon, isite_lat)
126 | return attri, np.max(attri, axis=1), np.argmax(attri, axis=1) + 1, \
127 | np.min(attri, axis=1), np.argmin(attri, axis=1) + 1
128 |
129 |
130 | if __name__ == '__main__':
131 | '''Examples.'''
132 | start_year = 2006
133 | end_year = 2015
134 | site_index = [(-2, 0), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-2, 5), (-2, 6),
135 | (-2, 7), (-2, 8), (-2, 9), (-2, 10), (-2, 11), (-2, 12), (-2, 13), (-2, 14),
136 | (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-3, 5), (-3, 6),
137 | (-3, 7), (-3, 8), (-3, 9), (-3, 10), (-3, 11), (-3, 12), (-3, 13), (-3, 14),
138 | (-4, 0), (-4, 1), (-4, 2), (-4, 3), (-4, 4), (-4, 5), (-4, 6),
139 | (-4, 7), (-4, 8), (-4, 9), (-4, 10), (-4, 11), (-4, 12), (-4, 13), (-4, 14),
140 | (-5, 0), (-5, 1), (-5, 2), (-5, 3), (-5, 4), (-5, 5), (-5, 6),
141 | (-5, 7), (-5, 8), (-5, 9), (-5, 10), (-5, 11), (-5, 12), (-5, 13), (-5, 14),
142 | (-6, 0), (-6, 1), (-6, 2), (-6, 3), (-6, 4), (-6, 5), (-6, 6),
143 | (-6, 7), (-6, 8), (-6, 9), (-6, 10), (-6, 11), (-6, 12), (-6, 13), (-6, 14),
144 | (-7, 0), (-7, 1), (-7, 2), (-7, 3), (-7, 4), (-7, 5), (-7, 6),
145 | (-7, 7), (-7, 8), (-7, 9), (-7, 10), (-7, 11), (-7, 12), (-7, 13), (-7, 14),
146 | (-8, 0), (-8, 1), (-8, 2), (-8, 3), (-8, 4), (-8, 5), (-8, 6),
147 | (-8, 7), (-8, 8), (-8, 9), (-8, 10), (-8, 11), (-8, 12), (-8, 13), (-8, 14),
148 | (-9, 0), (-9, 1), (-9, 2), (-9, 3), (-9, 4), (-9, 5), (-9, 6),
149 | (-9, 7), (-9, 8), (-9, 9), (-9, 10), (-9, 11), (-9, 12), (-9, 13), (-9, 14),
150 | (-10, 0), (-10, 1), (-10, 2), (-10, 3), (-10, 4), (-10, 5), (-10, 6),
151 | (-10, 7), (-10, 8), (-10, 9), (-10, 10), (-10, 11), (-10, 12), (-10, 13), (-10, 14),
152 | (-11, 0), (-11, 1), (-11, 2), (-11, 3), (-11, 4), (-11, 5), (-11, 6),
153 | (-11, 7), (-11, 8), (-11, 9), (-11, 10), (-11, 11), (-11, 12), (-11, 13), (-11, 14)]
154 | wfile_name = 'sd_wind_data'
155 | sfile_name = 'sd_solar_data'
156 |
157 | outline = (114, 34, 123, 38.5)
158 | names = ('CHN_adm_shp/CHN_adm3', 'NAME_1', 'Shandong')
159 | lat_lable = (34, 39, 0.5)
160 | lon_lable = (114, 124, 1)
161 | site_lon = [118, 118.667,
162 | 116.667, 117.333, 118, 118.667, 120, 120.667, 121.333, 122,
163 | 116, 116.667, 117.333, 118, 118.667, 119.333, 120, 120.667, 121.333, 122,
164 | 115.333, 116, 116.667, 117.333, 118, 118.667, 119.333, 120, 120.667,
165 | 115.333, 116, 116.667, 117.333, 118, 118.667, 119.333, 120, 120.667,
166 | 115.333, 116, 116.667, 117.333, 118, 118.667, 119.333,
167 | 115.333, 116, 116.667, 117.333, 118, 118.667,
168 | 115.333, 116, 117.333, 118]
169 | site_lat = [38, 38,
170 | 37.5, 37.5, 37.5, 37.5, 37.5, 37.5, 37.5, 37.5,
171 | 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
172 | 36.5, 36.5, 36.5, 36.5, 36.5, 36.5, 36.5, 36.5, 36.5,
173 | 36, 36, 36, 36, 36, 36, 36, 36, 36,
174 | 35.5, 35.5, 35.5, 35.5, 35.5, 35.5, 35.5,
175 | 35, 35, 35, 35, 35, 35,
176 | 34.5, 34.5, 34.5, 34.5]
177 |
178 | wind_data = mwind.WindData(wfile_name, site_index, start_year, end_year)
179 | wind_speed_ref = wind_data.cimport_data()
180 | wind_speed_hw = wind_data.cref2hw()
181 | wind_capacity_factor = wind_data.cwind2cf()
182 | solar_data = msolar.SolarData(sfile_name, site_index, start_year, end_year)
183 | solar_irrad_data = solar_data.cimport_data()
184 | solar_capacity_factor = solar_data.csolar2cf_model1()
185 | # solar_temperature_data = solar_data.cimport_datat()
186 | # solar_capacity_factor = solar_data.csolar2cf_model2()
187 |
188 | fc_mean_yearly = ass_wide_ws(wind_data, outline, names, lat_lable, lon_lable, site_lon, site_lat, 0)
189 | fc_std_hourly = ass_wide_ws(wind_data, outline, names, lat_lable, lon_lable, site_lon, site_lat, 1)
190 | fc_varcoef_hourly = ass_wide_ws(wind_data, outline, names, lat_lable, lon_lable, site_lon, site_lat, 2)
191 | fc_mean_hourly = ass_wide_ws(wind_data, outline, names, lat_lable, lon_lable, site_lon, site_lat, 3)
192 |
193 | hfc_mean_yearly = ass_wide_lsy(wind_data, solar_data, outline, names, lat_lable, lon_lable, site_lon, site_lat, 0)
194 | hfc_varcoef_hourly = ass_wide_lsy(wind_data, solar_data, outline, names, lat_lable, lon_lable, site_lon, site_lat, 1)
195 | improving_coef = ass_wide_lsy(wind_data, solar_data, outline, names, lat_lable, lon_lable, site_lon, site_lat, 2)
196 | local_synergy_coef = ass_wide_lsy(wind_data, solar_data, outline, names, lat_lable, lon_lable, site_lon, site_lat, 3)
197 |
198 | synergy_1coef_ww = ass_site_wsy(wind_data, solar_data, outline, names, lat_lable, lon_lable, site_lon, site_lat, 71, 0)
199 | synergy_1coef_ss = ass_site_wsy(wind_data, solar_data, outline, names, lat_lable, lon_lable, site_lon, site_lat, 71, 1)
200 | synergy_1coef_ws = ass_site_wsy(wind_data, solar_data, outline, names, lat_lable, lon_lable, site_lon, site_lat, 71, 2)
201 | synergy_1coef_sw = ass_site_wsy(wind_data, solar_data, outline, names, lat_lable, lon_lable, site_lon, site_lat, 71, 3)
--------------------------------------------------------------------------------
/ass_res/ass_widearea_wsy.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python
2 | # -*- coding: utf-8 -*-
3 | """
4 | Created on Sat Jun 10 11:12:21 2017
5 | ########################################################################################
6 | # @ File name: ass_widearea_wsy.py
7 | # @ Function: Perform wide-area assessment.
8 | # Assess the spatial synergy effects.
9 | # @ Author: Yongji Cao, Hengxu Zhang
10 | # @ Version: 1.0
11 | # @ Revision date: Jan/19/2018
12 | # @ Copyright (c) 2016-2018 School of Electrical Engineering, Shandong University, China
13 | ########################################################################################
14 | """
15 |
16 |
17 | import numpy as np
18 | from scipy import stats
19 | from sklearn.cluster import KMeans
20 | from sklearn.decomposition import PCA
21 | from sklearn.metrics import silhouette_samples, silhouette_score
22 |
23 | import init_nasa_wind as mwind
24 | import init_nasa_solar as msolar
25 | import draw_geo_fig as mdgf
26 |
27 |
28 | def ccalc_synergy_coef(iwind_data, isolar_data, imode=0, isiteth=0):
29 | '''Calculate the spatial synergy coefficients
30 | Args:
31 | iwind_data: the source wind data.
32 | isource_data: the source solar data.
33 | imode: 0, 1, 2, 3. the spatial wind-wind synergy coefficient, spatial solar-solar synergy coefficient,
34 | spatial wind-solar synergy coefficient, spatial solar-wind synergy coefficient
35 | isiteth: the serial number of the selected site.
36 | Returns:
37 | synergy_coef_nor: the spatial synergy coefficients.
38 | '''
39 | wf_10yearstl = iwind_data.c2style_10year(True)
40 | sf_10yearstl = isolar_data.c2style_10year(True)
41 | site_num = len(iwind_data.site_index)
42 | year_index = range(iwind_data.start_year, iwind_data.end_year + 1)
43 | year_num = len(year_index)
44 | if isiteth == 0:
45 | pearson_coef = np.zeros((site_num, site_num), np.float32)
46 | if imode == 0:
47 | fc_0 = wf_10yearstl
48 | fc_1 = wf_10yearstl
49 | elif imode == 1:
50 | fc_0 = sf_10yearstl
51 | fc_1 = sf_10yearstl
52 | elif imode == 2:
53 | fc_0 = wf_10yearstl
54 | fc_1 = sf_10yearstl
55 | else:
56 | fc_0 = sf_10yearstl
57 | fc_1 = wf_10yearstl
58 | for each_siteth0 in range(1, site_num + 1, 1):
59 | for each_siteth1 in range(1, site_num + 1, 1):
60 | pearson_coef[each_siteth0 - 1, each_siteth1 - 1] = \
61 | stats.pearsonr(fc_0[each_siteth0][0, :], fc_1[each_siteth1][0, :])[0]
62 | synergy_coef = (1 - pearson_coef) / 2.0
63 | synergy_coef_nor = np.empty((site_num, site_num), np.float32)
64 | for each_siteth in range(0, site_num, 1):
65 | synergy_coef_nor = \
66 | np.hstack((synergy_coef_nor, ((synergy_coef[:, each_siteth] - \
67 | np.min(synergy_coef[:, each_siteth])) / np.ptp(synergy_coef[:, each_siteth])).reshape(site_num, - 1)))
68 | else:
69 | pearson_coef = np.zeros((1, site_num), np.float32)
70 | if imode == 0:
71 | fc_0 = wf_10yearstl[isiteth]
72 | fc_1 = wf_10yearstl
73 | elif imode == 1:
74 | fc_0 = sf_10yearstl[isiteth]
75 | fc_1 = sf_10yearstl
76 | elif imode == 2:
77 | fc_0 = wf_10yearstl[isiteth]
78 | fc_1 = sf_10yearstl
79 | else:
80 | fc_0 = sf_10yearstl[isiteth]
81 | fc_1 = wf_10yearstl
82 | for each_siteth in range(1, site_num + 1, 1):
83 | pearson_coef[0, each_siteth - 1] = \
84 | stats.pearsonr(fc_0[0, :], fc_1[each_siteth][0, :])[0]
85 | synergy_coef = (1 - pearson_coef) / 2.0
86 | synergy_coef_nor = synergy_coef
87 | return synergy_coef_nor
88 |
89 |
90 | def csearch_centroid (idata_index, isy_coef, icluster_num=6):
91 | '''Search the centroid of each cluster.
92 | Args:
93 | idata_index: the clustering indices of source data.
94 | isy_coef: the spatial synergy coefficients processed by the PCA.
95 | icluster_num: the number of clusters.
96 | Returns:
97 | centroid_site + 1: the serial number of the searched centroids.
98 | '''
99 | centroid_site = np.zeros((1, icluster_num), np.float32)
100 | for each0 in range(0,icluster_num,1):
101 | num = len(idata_index[each0])
102 | tmp = np.zeros((1,num), np.float32)
103 | for each1 in range(num):
104 | for each2 in idata_index[each0]:
105 | if idata_index[each0][each1] != each2:
106 | tmp[0, each1] = tmp[0,each1] + ((isy_coef[idata_index[each0][each1], 0]) ** \
107 | 2 - (isy_coef[each2, 0]) ** 2) ** 0.5
108 | centroid_site[0, each0] = idata_index[each0][np.argmin(tmp)]
109 | return centroid_site + 1
110 |
111 |
112 | def cpca_and_cluster(ioutline, inames, ilat_lable, ilon_lable, isite_lon, isite_lat, isynergy_coef, icomponent_num=1, icluster_num=6):
113 | '''Assess the spatial synergy effects by the PCA and k-menas clustering.
114 | Args:
115 | ioutline: the outlines of the background.
116 | inames: the filename of geographical data, attribute/column name, and region name.
117 | ilat_lable: the latitude label.
118 | ilon_lable: the longitude label.
119 | isite_lon: the longitude of the annotated site.
120 | isite_lat: the latitude of the annotated sites.
121 | isynergy_coef: the spatial synergy coefficients.
122 | icomponent_num: the number of principal components.
123 | icluster_num: the number of clusters
124 | Returns:
125 | the graphs.
126 | pca_evr: the explained variance of each components of the PCA
127 | centroid_site: the serial number of the searched centroids.
128 | data_index: the clustering indices of source data.
129 | sycoef_pca_nor: he spatial synergy coefficients processed by the PCA.
130 | silhouette_avg: the average silhouette coefficients.
131 | silhouette_sample: the silhouette coefficients.
132 | '''
133 | pca_instance = PCA(n_components=icomponent_num)
134 | pca_instance.fit(isynergy_coef)
135 | pca_component = pca_instance.components_
136 | pca_evr = pca_instance.explained_variance_ratio_
137 |
138 | sycoef_pca = pca_instance.transform(isynergy_coef)
139 | sycoef_pca_nor = (sycoef_pca - np.mean(sycoef_pca, axis=0)) / np.std(sycoef_pca, axis=0)
140 | kmeans_instance = KMeans(n_clusters=icluster_num)
141 | sycoef_kmeans = kmeans_instance.fit(sycoef_pca_nor)
142 | sycoef_km_label = sycoef_kmeans.labels_
143 | sycoef_km_center = sycoef_kmeans.cluster_centers_
144 | sycoef_km_inertia = sycoef_kmeans.inertia_
145 | data_index = []
146 | for each_cluster in range(0, icluster_num, 1):
147 | data_index.append([x for x in range(0, isynergy_coef.shape[0]) if sycoef_km_label[x] == each_cluster])
148 | silhouette_avg = silhouette_score(sycoef_pca_nor, sycoef_km_label)
149 | silhouette_sample = silhouette_samples(sycoef_pca_nor, sycoef_km_label)
150 | centroid_site = csearch_centroid (data_index, sycoef_pca_nor, icluster_num)
151 | mdgf.cdraw_cluster_fig(data_index, icluster_num, ioutline, inames, ilat_lable, ilon_lable, isite_lon, isite_lat)
152 | return pca_evr, centroid_site, data_index, sycoef_pca_nor, silhouette_avg, silhouette_sample
153 |
154 |
155 | def canal_cluster(iwind_data, isolar_data, icentroid_site0, icentroid_site1, imode=0, icluster_num=6):
156 | '''Assess the spatial synergy effects by the PCA and k-menas clustering.
157 | Args:
158 | wind_data: the source wind data.
159 | isource_data: the source solar data.
160 | icentroid_site0: the serial number of the searched centroids of mode 0 of spatial synergy effects.
161 | icentroid_site1: the serial number of the searched centroids of mode 1 of spatial synergy effects.
162 | imode: 0, 1, 2, 3. the spatial wind-wind synergy coefficient, spatial solar-solar synergy coefficient,
163 | spatial wind-solar synergy coefficient, spatial solar-wind synergy coefficient
164 | icluster_num: the number of clusters
165 | Returns:
166 | the max value of the selected attribute.
167 | the serial number of site of the max value.
168 | the min value of the selected attribute.
169 | the serial number of site of the min value.
170 | '''
171 | wf_10yearstl = iwind_data.c2style_10year(True)
172 | sf_10yearstl = isolar_data.c2style_10year(True)
173 | synergy_coef = np.zeros((icluster_num, icluster_num), np.float32)
174 | if imode == 0:
175 | fc_0 = wf_10yearstl
176 | fc_1 = wf_10yearstl
177 | elif imode == 1:
178 | fc_0 = sf_10yearstl
179 | fc_1 = sf_10yearstl
180 | elif imode == 2:
181 | fc_0 = wf_10yearstl
182 | fc_1 = sf_10yearstl
183 | else:
184 | fc_0 = sf_10yearstl
185 | fc_1 = wf_10yearstl
186 | for each0 in range(0, icluster_num, 1):
187 | for each1 in range(0, icluster_num, 1):
188 | synergy_coef[each0, each1] = \
189 | stats.pearsonr(fc_0[icentroid_site0[0, each0]][0, :], fc_1[icentroid_site1[0, each1]][0, :])[0]
190 | synergy_coef = (1 - synergy_coef) /2.0
191 | return icentroid_site1[0, np.argmax(synergy_coef, axis=0)], np.max(synergy_coef, axis=0), \
192 | icentroid_site1[0, np.argmin(synergy_coef, axis=0)], np.min(synergy_coef, axis=0)
193 |
194 |
195 | if __name__ == '__main__':
196 | '''Examples.'''
197 | start_year = 2006
198 | end_year = 2015
199 | site_index = [(-3, 6), (-3, 7),
200 | (-4, 4), (-4, 5), (-4, 6), (-4, 7), (-4, 9), (-4, 10), (-4, 11), (-4, 12),
201 | (-5, 3), (-5, 4), (-5, 5), (-5, 6), (-5, 7), (-5, 8), (-5, 9), (-5, 10), (-5, 11), (-5, 12),
202 | (-6, 2), (-6, 3), (-6, 4), (-6, 5), (-6, 6), (-6, 7), (-6, 8), (-6, 9), (-6, 10),
203 | (-7, 2), (-7, 3), (-7, 4), (-7, 5), (-7, 6), (-7, 7), (-7, 8), (-7, 9), (-7, 10),
204 | (-8, 2), (-8, 3), (-8, 4), (-8, 5), (-8, 6), (-8, 7), (-8, 8),
205 | (-9, 2), (-9, 3), (-9, 4), (-9, 5), (-9, 6), (-9, 7),
206 | (-10, 2), (-10, 3), (-10, 5), (-10, 6)]
207 | wfile_name = 'sd_wind_data'
208 | sfile_name = 'sd_solar_data'
209 |
210 | outline = (114, 34, 123, 38.5)
211 | names = ('CHN_adm_shp/CHN_adm3', 'NAME_1', 'Shandong')
212 | lat_lable = (34, 39, 0.5)
213 | lon_lable = (114, 124, 1)
214 | site_lon = [118, 118.667,
215 | 116.667, 117.333, 118, 118.667, 120, 120.667, 121.333, 122,
216 | 116, 116.667, 117.333, 118, 118.667, 119.333, 120, 120.667, 121.333, 122,
217 | 115.333, 116, 116.667, 117.333, 118, 118.667, 119.333, 120, 120.667,
218 | 115.333, 116, 116.667, 117.333, 118, 118.667, 119.333, 120, 120.667,
219 | 115.333, 116, 116.667, 117.333, 118, 118.667, 119.333,
220 | 115.333, 116, 116.667, 117.333, 118, 118.667,
221 | 115.333, 116, 117.333, 118]
222 | site_lat = [38, 38,
223 | 37.5, 37.5, 37.5, 37.5, 37.5, 37.5, 37.5, 37.5,
224 | 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
225 | 36.5, 36.5, 36.5, 36.5, 36.5, 36.5, 36.5, 36.5, 36.5,
226 | 36, 36, 36, 36, 36, 36, 36, 36, 36,
227 | 35.5, 35.5, 35.5, 35.5, 35.5, 35.5, 35.5,
228 | 35, 35, 35, 35, 35, 35,
229 | 34.5, 34.5, 34.5, 34.5]
230 |
231 | wind_data = mwind.WindData(wfile_name, site_index, start_year, end_year)
232 | wind_speed_ref = wind_data.cimport_data()
233 | wind_speed_hw = wind_data.cref2hw()
234 | wind_capacity_factor = wind_data.cwind2cf()
235 | solar_data = msolar.SolarData(sfile_name, site_index, start_year, end_year)
236 | solar_irrad_data = solar_data.cimport_data()
237 | solar_capacity_factor = solar_data.csolar2cf_model1()
238 | # solar_temperature_data = solar_data.cimport_datat()
239 | # solar_capacity_factor = solar_data.csolar2cf_model2()
240 |
241 | synergy_coef_ww = ccalc_synergy_coef(wind_data, solar_data, 0, 0)
242 | assess_result_ww = cpca_and_cluster(outline, names, lat_lable, lon_lable, site_lon, site_lat, synergy_coef_ww, 3, 6)
243 |
244 | assresult_centroid_ww=canal_cluster(wind_data, solar_data, assess_result_ww[1], assess_result_ww[1], 0, 6)
245 |
--------------------------------------------------------------------------------
/ass_res/draw_geo_fig.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python
2 | # -*- coding: utf-8 -*-
3 | """
4 | Created on Fri Jun 09 20:40:31 2017
5 | ########################################################################################
6 | # @ File name: draw_geo_fig.py
7 | # @ Function: Draw geographical graphs.
8 | # Basic graphs, contour graphs, and clustering graphs.
9 | # @ Author: Yongji Cao, Hengxu Zhang
10 | # @ Version: 1.0
11 | # @ Revision date: Jan/19/2018
12 | # @ Copyright (c) 2016-2018 School of Electrical Engineering, Shandong University, China
13 | ########################################################################################
14 | """
15 |
16 |
17 | import numpy as np
18 | import matplotlib.pyplot as plt
19 | from mpl_toolkits.basemap import Basemap
20 |
21 |
22 | def anno_txt(imap, isite_lon, isite_lat, itxt, imode=False, imarker='.', icolor='k', ilabelname='Cluster 1'):
23 | '''Annotate on the geographical graphs.
24 | Args:
25 | imap: the handle of the geographical graphs.
26 | isite_lon: the longitude of the annotated site.
27 | isite_lat: the latitude of the annotated sites.
28 | itxt: the annotated text.
29 | imode: True or False. Annote labelname or not.
30 | imarker: the annotated marker.
31 | icolor: the annotated colar.
32 | ilabelname: the labelname.
33 | Returns:
34 | null.
35 | '''
36 | x0, y0 = imap(isite_lon, isite_lat)
37 | if imode == True:
38 | imap.scatter(x0, y0, marker=imarker, color=icolor, label=ilabelname)
39 | else:
40 | imap.scatter(x0, y0, marker=imarker, color=icolor,)
41 | for x1, y1, z1 in zip(x0, y0, itxt):
42 | plt.text(x1, y1, z1, fontweight='bold', fontsize=12, ha='left',
43 | va='bottom', color=icolor)
44 |
45 |
46 | def cdraw_geo_ax(iax, ioutline, inames, ilat_lable, ilon_lable):
47 | '''Draw the geographical graphs on the given ax.
48 | Args:
49 | iax: the handle of given ax.
50 | ioutline: the outlines of the background.
51 | inames: the filename of geographical data, attribute/column name, and region name.
52 | ilat_lable: the latitude label.
53 | ilon_lable: the longitude label.
54 | Returns:
55 | bmap: the handle of the geographical graphs.
56 | '''
57 | illlong = ioutline[0]
58 | illlat = ioutline[1]
59 | iurlong = ioutline[2]
60 | iurlat = ioutline[3]
61 | bmap = Basemap(llcrnrlon=illlong, llcrnrlat=illlat, urcrnrlon=iurlong,
62 | urcrnrlat=iurlat, projection='cyl', ax=iax)
63 | ifile_name = inames[0]
64 | iinfo_name = inames[1]
65 | iobj_name = inames[2]
66 | shp_info = bmap.readshapefile(ifile_name, 'states', drawbounds=False)
67 | for info, shp in zip(bmap.states_info, bmap.states):
68 | proid = info[iinfo_name]
69 | if proid == iobj_name:
70 | xc, yc = zip(*shp)
71 | bmap.plot(xc, yc, marker=None, color='k', lw=0.7)
72 | bmap.drawcountries()
73 | ilat_start = ilat_lable[0]
74 | ilat_end = ilat_lable[1]
75 | ilat_step = ilat_lable[2]
76 | ilon_start = ilon_lable[0]
77 | ilon_end = ilon_lable[1]
78 | ilon_step = ilon_lable[2]
79 | bmap.drawparallels(np.arange(ilat_start, ilat_end, ilat_step), labels=[1, 0, 0, 0])
80 | bmap.drawmeridians(np.arange(ilon_start, ilon_end, ilon_step), labels=[0, 0, 0, 1])
81 | return bmap
82 |
83 |
84 | def cdraw_basic_fig(ioutline, inames, ilat_lable, ilon_lable, isite_lon, isite_lat):
85 | '''Draw the basic geographical graphs.
86 | Args:
87 | ioutline: the outlines of the background.
88 | inames: the filename of geographical data, attribute/column name, and region name.
89 | ilat_lable: the latitude label.
90 | ilon_lable: the longitude label.
91 | isite_lon: the longitude of the annotated site.
92 | isite_lat: the latitude of the annotated sites.
93 | Returns:
94 | the basic geographical graphs.
95 | '''
96 | fig = plt.figure(dpi=300)
97 | plt.rcParams['font.family'] = 'Times New Roman'
98 | axc = fig.add_subplot(111)
99 | bmapc = cdraw_geo_ax(axc, ioutline, inames, ilat_lable, ilon_lable)
100 | siteth = [str(x) for x in range(1, len(isite_lon) + 1, 1)]
101 | anno_txt(bmapc, isite_lon, isite_lat, siteth)
102 | axc.set_xlabel(r'Longitude ($\mathrm{^\circ}$)', labelpad=13)
103 | axc.set_ylabel(r'Latitude ($\mathrm{^\circ}$)', labelpad=34)
104 | plt.title('The geographical graph')
105 | plt.show()
106 | # plt.savefig('Geo_graph.png', dpi=300, bbox_inches='tight')
107 |
108 |
109 | def cdraw_contour_fig(idata, ioutline, inames, ilat_lable, ilon_lable, isite_lon, isite_lat):
110 | '''Draw the contour geographical graphs.
111 | Args:
112 | idata: the source data
113 | ioutline: the outlines of the background.
114 | inames: the filename of geographical data, attribute/column name, and region name.
115 | ilat_lable: the latitude label.
116 | ilon_lable: the longitude label.
117 | isite_lon: the longitude of the annotated site.
118 | isite_lat: the latitude of the annotated sites.
119 | Returns:
120 | the contour geographical graphs.
121 | '''
122 | fig = plt.figure(dpi=300)
123 | plt.rcParams['font.family'] = 'Times New Roman'
124 | axc = fig.add_subplot(111)
125 | siteth = [str(x) for x in range(1, len(isite_lon) + 1, 1)]
126 | lon0_num = (ioutline[2] + 1 - ioutline[0]) /2 *3 + 1
127 | lon0 = np.linspace(ioutline[0], ioutline[2] + 1, lon0_num)[0: -1]
128 | lat0_num = (ioutline[3] - ioutline[1]) * 2 + 1
129 | lat0 = np.linspace(ioutline[3], ioutline[1], lat0_num)
130 | lon1, lat1 = np.meshgrid(lon0, lat0)
131 | bmapc = cdraw_geo_ax(axc, ioutline, inames, ilat_lable, ilon_lable)
132 | data_reshape = idata.reshape((int(lat0_num), int(lon0_num) - 1))
133 | contourc = bmapc.contourf(lon1, lat1, data_reshape, cmap=plt.cm.jet)
134 | barc = bmapc.colorbar(contourc, location='bottom', pad="11%")
135 | anno_txt(bmapc, isite_lon, isite_lat, siteth)
136 | plt.title('The geographical contour')
137 | plt.show()
138 | # plt.savefig('Geo_contour.png', dpi=300, bbox_inches='tight')
139 |
140 |
141 | def cdraw_cluster_fig(idata_index, icluster_num, ioutline, inames, ilat_lable, ilon_lable, isite_lon, isite_lat):
142 | '''Draw the clustering geographical graphs.
143 | Args:
144 | idata_index: the clustering indices of source data.
145 | icluster_num: the number of clusters.
146 | ioutline: the outlines of the background.
147 | inames: the filename of geographical data, attribute/column name, and region name.
148 | ilat_lable: the latitude label.
149 | ilon_lable: the longitude label.
150 | isite_lon: the longitude of the annotated site.
151 | isite_lat: the latitude of the annotated sites.
152 | Returns:
153 | the clustering geographical graphs.
154 | '''
155 | fig = plt.figure(dpi=300)
156 | plt.rcParams['font.family'] = 'Times New Roman'
157 | axc = fig.add_subplot(111)
158 | siteth = [str(x) for x in range(1, len(isite_lon) + 1, 1)]
159 | bmapc = cdraw_geo_ax(axc, ioutline, inames, ilat_lable, ilon_lable)
160 | marker_list = ['.', 'o', '^', 'd', 's', 'h']
161 | color_list = ['k', 'r', 'b', 'g', 'm', 'c']
162 | labelname_list = ['Cluster 1', 'Cluster 2', 'Cluster 3', 'Cluster 4', 'Cluster 5', 'Cluster 6']
163 | siteth = [str(x) for x in range(1, len(isite_lon) + 1, 1)]
164 | for each0 in range(0, icluster_num):
165 | lonth_list = []
166 | latth_list = []
167 | siteth_list = []
168 | for each1 in idata_index[each0]:
169 | lonth_list.append(isite_lon[each1])
170 | latth_list.append(isite_lat[each1])
171 | siteth_list.append(siteth[each1])
172 | anno_txt(bmapc, lonth_list, latth_list, siteth_list, True, marker_list[each0], color_list[each0], labelname_list[each0])
173 | # plt.legend(loc=3,ncol=3)
174 | plt.legend(fontsize=9, loc=4, ncol=1)
175 | # plt.savefig('clusteringWW.png', dpi=300, bbox_inches='tight')
176 | plt.title('The clustering graph')
177 | plt.show()
178 |
179 |
180 | if __name__ == '__main__':
181 | '''Examples.'''
182 | outline = (114, 34, 123, 38.5)
183 | names = ('CHN_adm_shp/CHN_adm3', 'NAME_1', 'Shandong')
184 | lat_lable = (34, 39, 0.5)
185 | lon_lable = (114, 124, 1)
186 | site_lon = [118, 118.667,
187 | 116.667, 117.333, 118, 118.667, 120, 120.667, 121.333, 122,
188 | 116, 116.667, 117.333, 118, 118.667, 119.333, 120, 120.667, 121.333, 122,
189 | 115.333, 116, 116.667, 117.333, 118, 118.667, 119.333, 120, 120.667,
190 | 115.333, 116, 116.667, 117.333, 118, 118.667, 119.333, 120, 120.667,
191 | 115.333, 116, 116.667, 117.333, 118, 118.667, 119.333,
192 | 115.333, 116, 116.667, 117.333, 118, 118.667,
193 | 115.333, 116, 117.333, 118]
194 | site_lat = [38, 38,
195 | 37.5, 37.5, 37.5, 37.5, 37.5, 37.5, 37.5, 37.5,
196 | 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
197 | 36.5, 36.5, 36.5, 36.5, 36.5, 36.5, 36.5, 36.5, 36.5,
198 | 36, 36, 36, 36, 36, 36, 36, 36, 36,
199 | 35.5, 35.5, 35.5, 35.5, 35.5, 35.5, 35.5,
200 | 35, 35, 35, 35, 35, 35,
201 | 34.5, 34.5, 34.5, 34.5]
202 |
203 | cdraw_basic_fig(outline, names, lat_lable, lon_lable, site_lon, site_lat)
204 | # cdraw_contour_fig(c1HyMean, outline, names, lat_lable, lon_lable, site_lon, site_lat)
205 | # cdraw_cluster_fig(indexWW, kWW.n_clusters, outline, names, lat_lable, lon_lable, site_lon, site_lat)
--------------------------------------------------------------------------------
/ass_res/init_nasa_solar.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python
2 | # -*- coding: utf-8 -*-
3 | """
4 | Created on Thu Jun 08 21:53:47 2017
5 | ########################################################################################
6 | # @ File name: init_nasa_solar.py
7 | # @ Function: The class of NASA solar irradiation.
8 | # Importing, preprocessing, and basic operation of solar data.
9 | # @ Author: Yongji Cao, Hengxu Zhang
10 | # @ Version: 1.0
11 | # @ Revision date: Jan/19/2018
12 | # @ Copyright (c) 2016-2018 School of Electrical Engineering, Shandong University, China
13 | ########################################################################################
14 | """
15 |
16 |
17 | import numpy as np
18 | from pyhdf.SD import SD
19 |
20 |
21 | class SolarData(object):
22 | '''NASA solar irradiation data class'''
23 | version = '1.0'
24 | month_name = ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
25 | 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec')
26 | leap_year = {'Jan': (31, 101, 131, True), 'Feb': (29, 201, 229, True), 'Mar': (31, 301, 331, True),
27 | 'Apr': (30, 401, 430, True), 'May': (31, 501, 531, True), 'Jun': (30, 601, 630, True),
28 | 'Jul': (31, 701, 731, True), 'Aug': (31, 801, 831, True), 'Sep': (30, 901, 930, True),
29 | 'Oct': (31, 1001, 1031, False), 'Nov':(30, 1101, 1130, False), 'Dec':(31, 1201, 1231, False)}
30 | nonleap_year = {'Jan':(31, 101, 131, True), 'Feb':(28, 201, 228, True), 'Mar':(31, 301, 331, True),
31 | 'Apr': (30, 401, 430, True), 'May': (31, 501, 531, True), 'Jun': (30, 601, 630, True), 'Jul': (31, 701, 731, True),
32 | 'Aug': (31, 801, 831, True), 'Sep': (30, 901, 930, True), 'Oct': (31, 1001, 1031, False),
33 | 'Nov': (30, 1101, 1130, False), 'Dec': (31, 1201, 1231, False)}
34 | #fnamesa and fnamsb are the middle names of sloar irrdiation.
35 | fnamesa = '/MERRA301.prod.assim.tavg1_2d_rad_Nx.'
36 | fnamesb = '/MERRA300.prod.assim.tavg1_2d_rad_Nx.'
37 | fnamee = '.SUB.hdf'
38 | #fnameta and fnamtb are the middle names of ambient temperature.
39 | fnameta = '/MERRA301.prod.assim.tavg1_2d_slv_Nx.'
40 | fnametb = '/MERRA300.prod.assim.tavg1_2d_slv_Nx.'
41 | spl_month2010 = ('Jun', 'Jul', 'Aug')
42 |
43 | def __init__(self, ifile_path, isite_index, istart_year, iend_year):
44 | '''Create an object.
45 | Args:
46 | ifile_name: str; the folder name of NASA file.
47 | isite_index: list; the list site indice in NASA file.
48 | istart_year: int; the start year.
49 | iend_year: inlt; the end year.
50 | Returns:
51 | an instances
52 | '''
53 | self.file_path = ifile_path
54 | self.site_index = isite_index
55 | self.start_year = istart_year
56 | self.end_year = iend_year
57 | self.dict_solar = {}
58 | self.dict_solar_cf = {}
59 | self.dict_wind_cf0 = {}
60 | self.dict_temperature = {}
61 | self.alpha = 1
62 |
63 | def cimport_data(self, idata_name=('SWGNT',)):
64 | '''Import ten-year dsolar irradiation ata.
65 | Args:
66 | idata_name: the data name.
67 | Returns:
68 | self.dict_solar: imported data.
69 | '''
70 | year_index = range(self.start_year, self.end_year + 1)
71 | site_num = len(self.site_index)
72 | zero = str(0)
73 | for each_siteth in range(1, site_num + 1):
74 | self.dict_solar[each_siteth] = {}
75 | for each_year in year_index:
76 | self.dict_solar[each_siteth][each_year] = {}
77 | for each_month in SolarData.month_name:
78 | self.dict_solar[each_siteth][each_year][each_month] = np.empty((0,24), np.float32)
79 | for each_year in year_index:
80 | if ((each_year % 400 == 0) or ((each_year % 4 == 0) and (each_year % 100 != 0))):
81 | year_feature = SolarData.leap_year
82 | else:
83 | year_feature = SolarData.nonleap_year
84 | for each_month in SolarData.month_name:
85 | if ((each_year < 2010) or ((each_year == 2010) and (each_month in SolarData.spl_month2010))):
86 | fnames = self.file_path + SolarData.fnamesa
87 | else:
88 | fnames = self.file_path + SolarData.fnamesb
89 | day_s = year_feature[each_month][1]
90 | day_e = year_feature[each_month][2]
91 | if year_feature[each_month][3]:
92 | for each_day in range(day_s, day_e + 1):
93 | fname = fnames + str(each_year) + zero + str(each_day) + SolarData.fnamee
94 | print fname
95 | fid = SD(fname)
96 | tmpirrad = fid.select(idata_name[0])[:, :, :]
97 | fid.end()
98 | for each_siteth in range(1, site_num + 1):
99 | tmpirrad_site = tmpirrad[:, self.site_index[each_siteth - 1][0], \
100 | self.site_index[each_siteth - 1][1]].reshape(1, -1)
101 | self.dict_solar[each_siteth][each_year][each_month] = \
102 | np.vstack((self.dict_solar[each_siteth][each_year][each_month], tmpirrad_site))
103 | else:
104 | for each_day in range(day_s, day_e + 1):
105 | fname = fnames + str(each_year) + str(each_day) + SolarData.fnamee
106 | print fname
107 | fid = SD(fname)
108 | tmpirrad = fid.select(idata_name[0])[:, :, :]
109 | fid.end()
110 | for each_siteth in range(1, site_num + 1):
111 | tmpirrad_site = tmpirrad[:, self.site_index[each_siteth - 1][0], \
112 | self.site_index[each_siteth - 1][1]].reshape(1, -1)
113 | self.dict_solar[each_siteth][each_year][each_month] = \
114 | np.vstack((self.dict_solar[each_siteth][each_year][each_month], tmpirrad_site))
115 | return self.dict_solar
116 |
117 | def cimport_datat(self, idata_name=('TS',)):
118 | '''Import ten-year ambient temperature data.
119 | Args:
120 | idata_name: the data name.
121 | Returns:
122 | self.dict_solar: imported data.
123 | '''
124 | year_index = range(self.start_year, self.end_year + 1)
125 | site_num = len(self.site_indext)
126 | zero = str(0)
127 | for each_siteth in range(1, site_num + 1):
128 | self.dict_temperature[each_siteth] = {}
129 | for each_year in year_index:
130 | self.dict_temperature[each_siteth][each_year] = {}
131 | for each_month in SolarData.month_name:
132 | self.dict_temperature[each_siteth][each_year][each_month] = np.empty((0,24), np.float32)
133 | for each_year in year_index:
134 | if ((each_year % 400 == 0) or ((each_year % 4 == 0) and (each_year % 100 != 0))):
135 | year_feature = SolarData.leap_year
136 | else:
137 | year_feature = SolarData.nonleap_year
138 | for each_month in SolarData.month_name:
139 | if ((each_year == 2010) and (each_month in SolarData.spl_month2010)):
140 | fnames = self.file_patht + SolarData.fnameta
141 | else:
142 | fnames = self.file_patht + SolarData.fnametb
143 | day_s = year_feature[each_month][1]
144 | day_e = year_feature[each_month][2]
145 | if year_feature[each_month][3]:
146 | for each_day in range(day_s, day_e + 1):
147 | fname = fnames + str(each_year) + zero + str(each_day) + SolarData.fnamee
148 | print fname
149 | fid = SD(fname)
150 | tmpirrad = fid.select(idata_name[0])[:, :, :]
151 | fid.end()
152 | for each_siteth in range(1, site_num + 1):
153 | tmpirrad_site = tmpirrad[:, self.site_indext[each_siteth - 1][0], \
154 | self.site_indext[each_siteth - 1][1]].reshape(1, -1)
155 | self.dict_temperature[each_siteth][each_year][each_month] = \
156 | np.vstack((self.dict_temperature[each_siteth][each_year][each_month], tmpirrad_site))
157 | # print(tmpirrad_site)
158 | else:
159 | for each_day in range(day_s, day_e + 1):
160 | fname = fnames + str(each_year) + str(each_day) + SolarData.fnamee
161 | print fname
162 | fid = SD(fname)
163 | tmpirrad = fid.select(idata_name[0])[:, :, :]
164 | fid.end()
165 | for each_siteth in range(1, site_num + 1):
166 | tmpirrad_site = tmpirrad[:, self.site_indext[each_siteth - 1][0], \
167 | self.site_indext[each_siteth - 1][1]].reshape(1, -1)
168 | self.dict_temperature[each_siteth][each_year][each_month] = \
169 | np.vstack((self.dict_temperature[each_siteth][each_year][each_month], tmpirrad_site))
170 | # print(tmpirrad_site)
171 | return self.dict_temperature
172 |
173 | def csolar2cf_model1(self, irated_powr=255.0, iarea_m2=1.6368, ieffi_ratio=0.1248):
174 | '''Converter solar irradiation to capacity factors.
175 | PV Model1: Ff = (idata * iarea_m2 * ieffi_ratio) / ieffi_ratio
176 | Args:
177 | idata: the source solar irradiation.
178 | irated_powr: the rated power.
179 | iarea_m2: the area of a PV module.
180 | ieffi_ratio: the efficiency.
181 | Returns:
182 | capacity factors
183 | '''
184 | year_index = range(self.start_year, self.end_year + 1)
185 | site_num = len(self.site_index)
186 | for each_siteth in range(1, site_num + 1):
187 | self.dict_solar_cf[each_siteth] = {}
188 | for each_year in year_index:
189 | self.dict_solar_cf[each_siteth][each_year] = {}
190 | for each_month in SolarData.month_name:
191 | self.dict_solar_cf[each_siteth][each_year][each_month] = \
192 | self.dict_solar[each_siteth][each_year][each_month] * ieffi_ratio * iarea_m2 / irated_powr
193 | return self.dict_solar_cf
194 |
195 | def csolar2cf_model2(self, iHSTC=1000.0, iC1=0.93, iC2=-0.005, iTSTC=25.0, iTfTETC=47.0, iTaTETC=20.0, iHTETC=800.0):
196 | '''Converter solar irradiation to capacity factors.
197 | PV Model2: Ff = (idataf / iHSTC) * iC1 * (1 + iC2(Tf - iTSTC))
198 | Tf = idatat + idataf * (iTfTETC - iTaTETC) / iHTETC
199 | Args:
200 | idata: the source solar irradiation and ambient temperature.
201 | iHSTC: the solar irradiation at standard test condition.
202 | iC1: the derating coefficient.
203 | iC2: the power temperature coefficient.
204 | iTSTC: is the temperature at standard test condition.
205 | iTfTETC: the solar irradiation at temperature estimation test condition.
206 | iTaTETC: the ambient temperature at temperature estimation test condition.
207 | Returns:
208 | capacity factors
209 | '''
210 | year_index = range(self.start_year, self.end_year + 1)
211 | site_num = len(self.site_index)
212 | for each_siteth in range(1, site_num + 1):
213 | self.dict_solar_cf[each_siteth] = {}
214 | for each_year in year_index:
215 | self.dict_solar_cf[each_siteth][each_year] = {}
216 | for each_month in SolarData.month_name:
217 | # print each_month
218 | self.dict_solar_cf[each_siteth][each_year][each_month] = \
219 | self.dict_solar[each_siteth][each_year][each_month] / iHSTC * iC1 * \
220 | (1 + iC2 * (self.dict_temperature[each_siteth][each_year][each_month]
221 | - 273.15 - iTSTC + self.dict_solar[each_siteth][each_year][each_month]
222 | * (iTfTETC - iTaTETC) / iHTETC))
223 | return self.dict_solar_cf
224 |
225 | def c2style_1month(self, imode=True):
226 | '''Converter NASA data to 1 month style.
227 | Args:
228 | imode: True or False; wind speed or capacity factors.
229 | Returns:
230 | dict_data_1month: data in 1 month style.
231 | '''
232 | if imode == True:
233 | dict_data = self.dict_solar_cf
234 | else:
235 | dict_data = self.dict_solar
236 | dict_data_1month = {}
237 | year_index = range(self.start_year, self.end_year + 1)
238 | site_num = len(self.site_index)
239 | for each_siteth in range(1, site_num + 1):
240 | dict_data_1month[each_siteth] = {}
241 | for each_year in year_index:
242 | dict_data_1month[each_siteth][each_year] = {}
243 | for each_month in SolarData.month_name:
244 | dict_data_1month[each_siteth][each_year][each_month] = \
245 | dict_data[each_siteth][each_year][each_month].reshape(1, -1)
246 | return dict_data_1month
247 |
248 | def c2style_1year(self, imode=True):
249 | '''Converter NASA data to 1 year style.
250 | Args:
251 | imode: True or False; wind speed or capacity factors.
252 | Returns:
253 | dict_data_1year: data in 1 year style.
254 | '''
255 | if imode == True:
256 | dict_data = self.dict_solar_cf
257 | else:
258 | dict_data = self.dict_solar
259 | dict_data_1year = {}
260 | year_index = range(self.start_year, self.end_year + 1)
261 | site_num = len(self.site_index)
262 | for each_siteth in range(1, site_num + 1):
263 | dict_data_1year[each_siteth] = {};
264 | for each_year in year_index:
265 | dict_data_1year[each_siteth][each_year] = np.empty((1, 0), np.float32)
266 | for each_month in SolarData.month_name:
267 | tmp = dict_data[each_siteth][each_year][each_month].reshape(1, -1)
268 | dict_data_1year[each_siteth][each_year] = np.hstack((dict_data_1year[each_siteth][each_year], tmp))
269 | return dict_data_1year
270 |
271 | def c2style_10year(self, imode=True):
272 | '''Converter NASA data to 10 years style.
273 | Args:
274 | imode: True or False; wind speed or capacity factors.
275 | Returns:
276 | dict_data_10year: data in 10 year style.
277 | '''
278 | dict_data_1year = self.c2style_1year(imode)
279 | dict_data_10year = {}
280 | year_index = range(self.start_year, self.end_year + 1)
281 | site_num = len(self.site_index)
282 | for each_siteth in range(1, site_num + 1):
283 | dict_data_10year[each_siteth] = np.empty((1, 0), np.float32)
284 | for each_year in year_index:
285 | dict_data_10year[each_siteth] = \
286 | np.hstack((dict_data_10year[each_siteth], dict_data_1year[each_siteth][each_year]))
287 | return dict_data_10year
288 |
289 | def cselect_1site_1day(self, isiteth, iyear, imonth, iday, imode=True):
290 | '''select data of 1 site, 1 day.
291 | Args:
292 | isiteth: the serial number of site.
293 | iyear: the year.
294 | imonth: the month.
295 | iday: the day.
296 | imode: True or False; wind speed or capacity factors.
297 | Returns:
298 | data of 1 site, 1 day.
299 | '''
300 | if imode == True:
301 | dict_data = self.dict_solar_cf
302 | else:
303 | dict_data = self.dict_solar
304 | return dict_data[isiteth][iyear][imonth][iday-1, :].reshape(1, -1)
305 |
306 | def cselect_1site_1month(self, isiteth, iyear, imonth, imode=True):
307 | '''select data of 1 site, 1 month.
308 | Args:
309 | isiteth: the serial number of site.
310 | iyear: the year.
311 | imonth: the month.
312 | imode: True or False; wind speed or capacity factors.
313 | Returns:
314 | data of 1 site, 1 month.
315 | '''
316 | return self.c2style_1month(imode)[isiteth][iyear][imonth]
317 |
318 | def cselect_1site_1year(self, isiteth, iyear, imode=True):
319 | '''select data of 1 site, 1 year.
320 | Args:
321 | isiteth: the serial number of site.
322 | iyear: the year.
323 | imode: True or False; wind speed or capacity factors.
324 | Returns:
325 | data of 1 site, 1 year.
326 | '''
327 | return self.c2style_1year(imode)[isiteth][iyear]
328 |
329 | def cselect_1site_10year(self, isiteth, imode=True):
330 | '''select data of 1 site in 10 year style.
331 | Args:
332 | isiteth: the serial number of site.
333 | imode: True or False; wind speed or capacity factors.
334 | Returns:
335 | data of 1 site, 10 year.
336 | '''
337 | return self.c2style_10year(imode)[isiteth]
338 |
339 | def ccal_corrcoef(self, irelmean=0.1183):
340 | '''Calculate the correction factors.
341 | Args:
342 | irelmean: the in-situ measured capacity factors,
343 | the annual average capacity factor of the study region.
344 | Returns:
345 | alpha: the calculated correction factor for the study region.
346 | '''
347 | dict_data_10year = self.c2style_10year(True)
348 | ur = irelmean
349 | N = len(self.site_indext)
350 | us = 0
351 | for each_siteth in range(1, N+1, 1):
352 | us += np.mean(dict_data_10year[each_siteth], axis=1)
353 | corfactors = ur * N * 1.0 / us
354 | self.alpha = corfactors[0,]
355 | return alpha[0,]
356 |
357 | def ccorrect_cf(self):
358 | '''Correct the simulated capacity factors in the study region.
359 | Args:
360 | Returns:
361 | dict_solar_cf0: the uncorrected capacity factors
362 | dict_solar_cf: the corrected capacity factors
363 | '''
364 | year_index = range(self.start_year, self.end_year + 1)
365 | site_num = len(self.site_index)
366 | for each_siteth in range(1, site_num + 1):
367 | self.dict_solar_cf0[each_siteth]={}
368 | for each_year in year_index:
369 | self.dict_solar_cf0[each_siteth][each_year]={}
370 | for each_month in SolarData.month_name:
371 | self.dict_solar_cf0[each_siteth][each_year][each_month] = self.dict_solar_cf[each_siteth][each_year][each_month]
372 | self.dict_solar_cf[each_siteth][each_year][each_month] = self.dict_solar_cf[each_siteth][each_year][each_month] * self.alpha
373 | return self.dict_solar_cf0, self.dict_solar_cf
374 |
375 |
376 |
377 | if __name__ == '__main__':
378 | '''Examples.'''
379 | file_name = 'sd_solar_data'
380 | file_namet = 'sd_temp_data'
381 | irrad_site_index = [(-3, 6), (-9, 7)]
382 | irrad_site_indext = [(252, 443), (252, 452)]
383 | start_year = 2006
384 | end_year = 2006
385 |
386 | solar_data = SolarData(file_name, file_namet, irrad_site_index, irrad_site_indext, start_year, end_year)
387 | solar_irrad_data = solar_data.cimport_data()
388 | solar_capacity_factor = solar_data.csolar2cf_model1()
389 | # solar_temperature_data = solar_data.cimport_datat()
390 | # solar_capacity_factor = solar_data.csolar2cf_model2()
391 | PVcorrcoef = solar_data.ccal_corrcoef(0.1183)
392 | (solar_capacity_factor0, solar_capacity_factor) = solar_data.ccorrect_cf()
393 | solar_cf_1monthstl = solar_data.c2style_1month()
394 | solar_cf_1yearstl = solar_data.c2style_1year()
395 | solar_cf_10yearstl = solar_data.c2style_10year()
396 | solar_cf_1s1day = solar_data.cselect_1site_1day(1, 2006, 'Jan', 22)
397 | solar_cf_1s1month = solar_data.cselect_1site_1month(1, 2006, 'Jan')
398 | solar_cf_1s1year = solar_data.cselect_1site_1year(1, 2006)
399 | solar_cf_1s10year = solar_data.cselect_1site_10year(1)
--------------------------------------------------------------------------------
/ass_res/init_nasa_wind.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python
2 | # -*- coding: utf-8 -*-
3 | """
4 | Created on Thu Jun 08 10:54:23 2017
5 | ########################################################################################
6 | # @ File name: init_nasa_wind.py
7 | # @ Function: The class of NASA wind speed.
8 | # Importing, preprocessing, and basic operation of solar data.
9 | # @ Author: Yongji Cao, Hengxu Zhang
10 | # @ Version: 1.0
11 | # @ Revision date: Jan/19/2018
12 | # @ Copyright (c) 2016-2018 School of Electrical Engineering, Shandong University, China
13 | ########################################################################################
14 | """
15 |
16 |
17 | import numpy as np
18 | from pyhdf.SD import SD
19 |
20 |
21 | class WindData(object):
22 | '''NASA wind speed data class'''
23 | version = '1.0'
24 | month_name = ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
25 | 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec')
26 | leap_year = {'Jan': (31, 101, 131, True), 'Feb': (29, 201, 229, True), 'Mar': (31, 301, 331, True),
27 | 'Apr': (30, 401, 430, True), 'May': (31, 501, 531, True), 'Jun': (30, 601, 630, True),
28 | 'Jul': (31, 701, 731, True), 'Aug': (31, 801, 831, True), 'Sep': (30, 901, 930, True),
29 | 'Oct': (31, 1001, 1031, False), 'Nov': (30, 1101, 1130, False), 'Dec': (31, 1201, 1231, False)}
30 | nonleap_year = {'Jan': (31,101,131,True), 'Feb': (28,201,228,True), 'Mar': (31, 301, 331, True),
31 | 'Apr': (30, 401, 430, True), 'May': (31, 501, 531, True), 'Jun': (30, 601, 630, True), 'Jul': (31, 701, 731, True),
32 | 'Aug': (31, 801, 831, True), 'Sep': (30, 901, 930, True), 'Oct': (31, 1001, 1031, False),
33 | 'Nov': (30, 1101, 1130, False), 'Dec': (31, 1201, 1231, False)}
34 | fnamesa = '/MERRA301.prod.assim.tavg1_2d_slv_Nx.'
35 | fnamesb = '/MERRA300.prod.assim.tavg1_2d_slv_Nx.'
36 | fnamee = '.SUB.hdf'
37 | spl_month2010 = ('Jun', 'Jul', 'Aug')
38 |
39 | def __init__(self, ifile_name, isite_index, istart_year, iend_year):
40 | """Create an object.
41 | Args:
42 | ifile_name: str; the folder name of NASA file.
43 | isite_index: list; the list site indice in NASA file.
44 | istart_year: int; the start year.
45 | iend_year: inlt; the end year.
46 | Returns:
47 | an instances
48 | """
49 |
50 | self.file_name = ifile_name
51 | self.site_index = isite_index
52 | self.start_year = istart_year
53 | self.end_year = iend_year
54 | self.dict_ref_wind = {}
55 | self.dict_hw_wind = {}
56 | self.dict_wind_cf = {}
57 | self.dict_wind_cf0 = {}
58 | self.alpha = 1
59 |
60 | def cuv2speed(self, u, v):
61 | '''Converter u and v to the wind speed.
62 | Args:
63 | u: the U data in NASA file.
64 | v: the V data in NASA file.
65 | Returns:
66 | the wind speed
67 | '''
68 | return (u ** 2 + v ** 2) ** 0.5
69 |
70 | def cimport_data(self, idata_name=('V50M', 'U50M')):
71 | '''Import ten-year data.
72 | Args:
73 | idata_name: the data name.
74 | Returns:
75 | self.dict_ref_wind: imported data.
76 | '''
77 | year_index = range(self.start_year, self.end_year + 1)
78 | site_num = len(self.site_index)
79 | zero = str(0)
80 | for each_siteth in range(1, site_num + 1):
81 | self.dict_ref_wind[each_siteth] = {}
82 | for each_year in year_index:
83 | self.dict_ref_wind[each_siteth][each_year] = {}
84 | for each_month in WindData.month_name:
85 | self.dict_ref_wind[each_siteth][each_year][each_month] = np.empty((0,24), np.float32)
86 | for each_year in year_index:
87 | if ((each_year % 400 == 0) or ((each_year % 4 == 0) and (each_year % 100 != 0))):
88 | year_feature = WindData.leap_year
89 | else:
90 | year_feature = WindData.nonleap_year
91 | for each_month in WindData.month_name:
92 | if ((each_year == 2010) and (each_month in WindData.spl_month2010)):
93 | fnames = self.file_name + WindData.fnamesa
94 | else:
95 | fnames = self.file_name + WindData.fnamesb
96 | day_s = year_feature[each_month][1]
97 | day_e = year_feature[each_month][2]
98 | if year_feature[each_month][3]:
99 | for each_day in range(day_s, day_e + 1):
100 | fname = fnames + str(each_year) + zero + str(each_day) + WindData.fnamee
101 | print fname
102 | fid = SD(fname)
103 | tmpv = fid.select(idata_name[0])[:, :, :]
104 | tmpu = fid.select(idata_name[1])[:, :, :]
105 | fid.end()
106 | for each_siteth in range(1, site_num + 1):
107 | tmpv_site = tmpv[:, self.site_index[each_siteth - 1][0], \
108 | self.site_index[each_siteth - 1][1]].reshape(1, -1)
109 | tmpu_site = tmpu[:, self.site_index[each_siteth - 1][0], \
110 | self.site_index[each_siteth - 1][1]].reshape(1, -1)
111 | tmpwind_site = self.cuv2speed(tmpv_site, tmpu_site)
112 | self.dict_ref_wind[each_siteth][each_year][each_month] = \
113 | np.vstack((self.dict_ref_wind[each_siteth][each_year][each_month], tmpwind_site))
114 | else:
115 | for each_day in range(day_s, day_e + 1):
116 | fname = fnames + str(each_year) + str(each_day) + WindData.fnamee
117 | print fname
118 | fid = SD(fname)
119 | tmpv = fid.select(idata_name[0])[:, :, :]
120 | tmpu = fid.select(idata_name[1])[:, :, :]
121 | fid.end()
122 | for each_siteth in range(1, site_num + 1):
123 | tmpv_site = tmpv[:, self.site_index[each_siteth - 1][0], \
124 | self.site_index[each_siteth-1][1]].reshape(1, -1)
125 | tmpu_site = tmpu[:, self.site_index[each_siteth - 1][0], \
126 | self.site_index[each_siteth-1][1]].reshape(1, -1)
127 | tmpwind_site = self.cuv2speed(tmpv_site,tmpu_site)
128 | self.dict_ref_wind[each_siteth][each_year][each_month] = \
129 | np.vstack((self.dict_ref_wind[each_siteth][each_year][each_month], tmpwind_site))
130 | return self.dict_ref_wind
131 |
132 | def cref2hw(self, ihref=50.0, ihw=65.0, ialpha=0.35):
133 | '''Converter the speed at reference height to the one at WTGs height.
134 | Args:
135 | ihref: the reference height.
136 | ihref: the WTGs height.
137 | ialpha: the exponent coefficient
138 | Returns:
139 | self.dict_hw_wind: wind speed at WTGs height
140 | '''
141 | year_index = range(self.start_year, self.end_year+1)
142 | site_num = len(self.site_index)
143 | for each_siteth in range(1, site_num + 1):
144 | self.dict_hw_wind[each_siteth] = {}
145 | for each_year in year_index:
146 | self.dict_hw_wind[each_siteth][each_year] = {}
147 | for each_month in WindData.month_name:
148 | self.dict_hw_wind[each_siteth][each_year][each_month] = \
149 | self.dict_ref_wind[each_siteth][each_year][each_month] * (ihw / ihref) ** ialpha
150 | return self.dict_hw_wind
151 |
152 | def cuv2cf(self, idata, ispeed_in, ispeed_out, ispeed_rate, inita):
153 | '''Converter wind speed to capacity factors.
154 | Args:
155 | idata: the source wind speed.
156 | ispeed_in: cut-in speed.
157 | ispeed_out: cut-out speed.
158 | ispeed_rate: rate speed.
159 | inita: the efficiency.
160 | Returns:
161 | capacity factors
162 | '''
163 | return np.piecewise(
164 | idata,
165 | [np.logical_or(idata < ispeed_in, idata > ispeed_out),
166 | np.logical_and(idata >= ispeed_in, idata <= ispeed_rate),
167 | np.logical_and(idata > ispeed_rate, idata <= ispeed_out)],
168 | [0,
169 | lambda idata: (idata - ispeed_in) / (ispeed_rate - ispeed_in) * inita,
170 | 1 * inita])
171 |
172 | def cwind2cf(self, ispeed_in=3.0, ispeed_out=25.0, ispeed_rate=13.5, inita=0.95):
173 | '''Converter NASA wind speed to capacity factors.
174 | Args:
175 | idata: the source wind speed.
176 | ispeed_in: cut-in speed.
177 | ispeed_out: cut-out speed.
178 | ispeed_rate: rate speed.
179 | inita: the efficiency.
180 | Returns:
181 | self.dict_wind_cf: capacity factors
182 | '''
183 | year_index = range(self.start_year, self.end_year+1)
184 | site_num = len(self.site_index)
185 | for each_siteth in range(1, site_num + 1):
186 | self.dict_wind_cf[each_siteth]={}
187 | for each_year in year_index:
188 | self.dict_wind_cf[each_siteth][each_year]={}
189 | for each_month in WindData.month_name:
190 | self.dict_wind_cf[each_siteth][each_year][each_month] = \
191 | self.cuv2cf(self.dict_hw_wind[each_siteth][each_year][each_month], \
192 | ispeed_in, ispeed_out, ispeed_rate, inita)
193 | return self.dict_wind_cf
194 |
195 | def c2style_1month(self, imode=True):
196 | '''Converter NASA data to 1 month style.
197 | Args:
198 | imode: True or False; wind speed or capacity factors.
199 | Returns:
200 | dict_data_1month: data in 1 month style.
201 | '''
202 | if imode == True:
203 | dict_data = self.dict_wind_cf
204 | else:
205 | dict_data = self.dict_hw_wind
206 | dict_data_1month = {}
207 | year_index = range(self.start_year, self.end_year + 1)
208 | site_num = len(self.site_index)
209 | for each_siteth in range(1, site_num + 1):
210 | dict_data_1month[each_siteth] = {}
211 | for each_year in year_index:
212 | dict_data_1month[each_siteth][each_year] = {}
213 | for each_month in WindData.month_name:
214 | dict_data_1month[each_siteth][each_year][each_month] = \
215 | dict_data[each_siteth][each_year][each_month].reshape(1, -1)
216 | return dict_data_1month
217 |
218 | def c2style_1year(self, imode=True):
219 | '''Converter NASA data to 1 year style.
220 | Args:
221 | imode: True or False; wind speed or capacity factors.
222 | Returns:
223 | dict_data_1year: data in 1 year style.
224 | '''
225 | if imode == True:
226 | dict_data = self.dict_wind_cf
227 | else:
228 | dict_data = self.dict_hw_wind
229 | dict_data_1year = {}
230 | year_index = range(self.start_year, self.end_year + 1)
231 | site_num = len(self.site_index)
232 | for each_siteth in range(1, site_num + 1):
233 | dict_data_1year[each_siteth] = {};
234 | for each_year in year_index:
235 | dict_data_1year[each_siteth][each_year] = np.empty((1, 0), np.float32)
236 | for each_month in WindData.month_name:
237 | tmp = dict_data[each_siteth][each_year][each_month].reshape(1, -1)
238 | dict_data_1year[each_siteth][each_year] = np.hstack((dict_data_1year[each_siteth][each_year], tmp))
239 | return dict_data_1year
240 |
241 | def c2style_10year(self, imode=True):
242 | '''Converter NASA data to 10 years style.
243 | Args:
244 | imode: True or False; wind speed or capacity factors.
245 | Returns:
246 | dict_data_10year: data in 10 year style.
247 | '''
248 | dict_data_1year = self.c2style_1year(imode)
249 | dict_data_10year = {}
250 | year_index = range(self.start_year, self.end_year + 1)
251 | site_num = len(self.site_index)
252 | for each_siteth in range(1, site_num + 1):
253 | dict_data_10year[each_siteth] = np.empty((1, 0), np.float32)
254 | for each_year in year_index:
255 | dict_data_10year[each_siteth] = \
256 | np.hstack((dict_data_10year[each_siteth], dict_data_1year[each_siteth][each_year]))
257 | return dict_data_10year
258 |
259 | def cselect_1site_1day(self, isiteth, iyear, imonth, iday, imode=True):
260 | '''select data of 1 site, 1 day.
261 | Args:
262 | isiteth: the serial number of site.
263 | iyear: the year.
264 | imonth: the month.
265 | iday: the day.
266 | imode: True or False; wind speed or capacity factors.
267 | Returns:
268 | data of 1 site, 1 day.
269 | '''
270 | if imode == True:
271 | dict_data = self.dict_wind_cf
272 | else:
273 | dict_data = self.dict_hw_wind
274 | return dict_data[isiteth][iyear][imonth][iday-1, :].reshape(1, -1)
275 |
276 | def cselect_1site_1month(self, isiteth, iyear, imonth, imode=True):
277 | '''select data of 1 site, 1 month.
278 | Args:
279 | isiteth: the serial number of site.
280 | iyear: the year.
281 | imonth: the month.
282 | imode: True or False; wind speed or capacity factors.
283 | Returns:
284 | data of 1 site, 1 month.
285 | '''
286 | return self.c2style_1month(imode)[isiteth][iyear][imonth]
287 |
288 | def cselect_1site_1year(self, isiteth, iyear, imode=True):
289 | '''select data of 1 site, 1 year.
290 | Args:
291 | isiteth: the serial number of site.
292 | iyear: the year.
293 | imode: True or False; wind speed or capacity factors.
294 | Returns:
295 | data of 1 site, 1 year.
296 | '''
297 | return self.c2style_1year(imode)[isiteth][iyear]
298 |
299 | def cselect_1site_10year(self, isiteth, imode=True):
300 | '''select data of 1 site in 10 year style.
301 | Args:
302 | isiteth: the serial number of site.
303 | imode: True or False; wind speed or capacity factors.
304 | Returns:
305 | data of 1 site, 10 year.
306 | '''
307 | return self.c2style_10year(imode)[isiteth]
308 |
309 | def ccal_corrcoef(self, irelmean=0.2100):
310 | '''Calculate the correction factors.
311 | Args:
312 | irelmean: the in-situ measured capacity factors,
313 | the annual average capacity factor of the study region.
314 | Returns:
315 | alpha: the calculated correction factor for the study region.
316 | '''
317 | dict_data_10year = self.cdata2AllYearStyle(True)
318 | ur = irelmean
319 | N = len(self.ipoint_idex)
320 | us = 0
321 | for each_siteth in range(1, N+1, 1):
322 | us += np.mean(dict_data_10year[each_siteth], axis=1)
323 | corfactors = ur * N * 1.0 / us
324 | self.alpha = corfactors[0,]
325 | return self.alpha
326 |
327 | def ccorrect_cf(self):
328 | '''Correct the simulated capacity factors in the study region.
329 | Args:
330 | Returns:
331 | dict_wind_cf0: the uncorrected capacity factors
332 | dict_wind_cf: the corrected capacity factors
333 | '''
334 | year_index = range(self.start_year, self.end_year + 1)
335 | site_num = len(self.site_index)
336 | for each_siteth in range(1, site_num + 1):
337 | self.dict_wind_cf0[each_siteth]={}
338 | for each_year in year_index:
339 | self.dict_wind_cf0[each_siteth][each_year]={}
340 | for each_month in WindData.month_name:
341 | self.dict_wind_cf0[each_siteth][each_year][each_month] = self.dict_wind_cf[each_siteth][each_year][each_month]
342 | self.dict_wind_cf[each_siteth][each_year][each_month] = self.dict_wind_cf[each_siteth][each_year][each_month] * self.alpha
343 | return dict_wind_cf0, dict_wind_cf
344 |
345 | def
346 |
347 |
348 |
349 | if __name__ == '__main__':
350 | '''Examples.'''
351 | file_name = 'sd_wind_data'
352 | wind_site_index = [(-3, 6), (-9, 7)]
353 | start_year = 2006
354 | end_year = 2015
355 |
356 | wind_data = WindData(file_name, wind_site_index, start_year, end_year)
357 | wind_speed_ref = wind_data.cimport_data()
358 | wind_speed_hw = wind_data.cref2hw()
359 | wind_capacity_factor = wind_data.cwind2cf()
360 | WTGcorrcoef = wind_data.ccal_corrcoef(0.2100)
361 | (wind_capacity_factor0, wind_capacity_factor) = wind_data.ccorrect_cf()
362 | wind_cf_1monthstl = wind_data.c2style_1month()
363 | wind_cf_1yearstl = wind_data.c2style_1year()
364 | wind_cf_10yearstl = wind_data.c2style_10year()
365 | wind_cf_1s1day = wind_data.cselect_1site_1day(1, 2006, 'Jan', 22)
366 | wind_cf_1s1month = wind_data.cselect_1site_1month(1, 2006, 'Jan')
367 | wind_cf_1s1year = wind_data.cselect_1site_1year(1, 2006)
368 | wind_cf_1s10year = wind_data.cselect_1site_10year(1)
369 |
370 |
371 |
372 |
373 |
--------------------------------------------------------------------------------
/ass_res/sd_solar_data/sd_solar_data.txt:
--------------------------------------------------------------------------------
1 | The default path of the files of the ten-year NASA solar data.
--------------------------------------------------------------------------------
/ass_res/sd_temp_data/sd_temp_data.txt:
--------------------------------------------------------------------------------
1 | The default path of the files of the ten-year NASA temperature data.
--------------------------------------------------------------------------------
/ass_res/sd_wind_data/sd_wind_data.txt:
--------------------------------------------------------------------------------
1 | The default path of the files of the ten-year NASA wind data.
--------------------------------------------------------------------------------
/freq_a2c/README.md:
--------------------------------------------------------------------------------
1 | ######The description for freq_a2c ######
2 |
3 |
--------------------------------------------------------------------------------
/freq_a2c/c0122.out:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SDU-EDC/PowerXLab-Tools/58e19b2c1d768841697b6c120de37299b1ccbd2b/freq_a2c/c0122.out
--------------------------------------------------------------------------------
/freq_a2c/dsusr.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SDU-EDC/PowerXLab-Tools/58e19b2c1d768841697b6c120de37299b1ccbd2b/freq_a2c/dsusr.dll
--------------------------------------------------------------------------------